0s autopkgtest [17:23:40]: starting date and time: 2025-05-06 17:23:40+0000 0s autopkgtest [17:23:40]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [17:23:40]: host juju-7f2275-prod-proposed-migration-environment-15; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.5gob786k/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:python-hypothesis,src:python-tz,src:ca-certificates,src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=python-hypothesis/6.130.5-1 python-tz/2025.2-2 ca-certificates/20250419 matplotlib/3.10.1+dfsg1-3' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor builder-cpu4-ram8-disk100 --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-15@bos03-3.secgroup --name adt-questing-amd64-pandas-20250506-172340-juju-7f2275-prod-proposed-migration-environment-15-0cc471d2-e78e-4b82-b0d7-51078cff8a31 --image adt/ubuntu-questing-amd64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-15 --net-id=net_prod-proposed-migration-amd64 -e TERM=linux --mirror=http://ftpmaster.internal/ubuntu/ 58s autopkgtest [17:24:38]: testbed dpkg architecture: amd64 58s autopkgtest [17:24:38]: testbed apt version: 3.0.0 59s autopkgtest [17:24:39]: @@@@@@@@@@@@@@@@@@@@ test bed setup 59s autopkgtest [17:24:39]: testbed release detected to be: None 59s autopkgtest [17:24:39]: updating testbed package index (apt update) 60s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 60s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 60s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 60s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 60s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [27.3 kB] 60s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [580 kB] 60s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [67.8 kB] 60s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 Packages [137 kB] 60s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/main i386 Packages [94.4 kB] 60s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 Packages [656 kB] 60s Get:11 http://ftpmaster.internal/ubuntu questing-proposed/universe i386 Packages [262 kB] 60s Get:12 http://ftpmaster.internal/ubuntu questing-proposed/multiverse amd64 Packages [18.4 kB] 60s Get:13 http://ftpmaster.internal/ubuntu questing-proposed/multiverse i386 Packages [5028 B] 61s Fetched 1958 kB in 1s (2236 kB/s) 61s Reading package lists... 62s autopkgtest [17:24:42]: upgrading testbed (apt dist-upgrade and autopurge) 62s Reading package lists... 62s Building dependency tree... 62s Reading state information... 62s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 63s Starting 2 pkgProblemResolver with broken count: 0 63s Done 63s Entering ResolveByKeep 63s 63s Calculating upgrade... 63s The following packages will be upgraded: 63s ca-certificates gcc-15-base libatomic1 libdebuginfod-common 63s libdebuginfod1t64 libdw1t64 libelf1t64 libgcc-s1 libperl5.40 libstdc++6 63s lto-disabled-list perl perl-base perl-modules-5.40 python3-dbus 63s sensible-utils 64s 16 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 64s Need to get 11.8 MB of archives. 64s After this operation, 18.4 kB of additional disk space will be used. 64s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 libperl5.40 amd64 5.40.1-3 [4877 kB] 64s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 perl amd64 5.40.1-3 [262 kB] 64s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 perl-base amd64 5.40.1-3 [1840 kB] 64s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 perl-modules-5.40 all 5.40.1-3 [3217 kB] 64s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 libdebuginfod-common all 0.193-1 [15.6 kB] 64s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 libatomic1 amd64 15.1.0-2ubuntu1 [10.5 kB] 64s Get:7 http://ftpmaster.internal/ubuntu questing/main amd64 gcc-15-base amd64 15.1.0-2ubuntu1 [54.6 kB] 64s Get:8 http://ftpmaster.internal/ubuntu questing/main amd64 libgcc-s1 amd64 15.1.0-2ubuntu1 [78.1 kB] 64s Get:9 http://ftpmaster.internal/ubuntu questing/main amd64 libstdc++6 amd64 15.1.0-2ubuntu1 [812 kB] 64s Get:10 http://ftpmaster.internal/ubuntu questing/main amd64 sensible-utils all 0.0.25 [25.0 kB] 64s Get:11 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 ca-certificates all 20250419 [163 kB] 64s Get:12 http://ftpmaster.internal/ubuntu questing/main amd64 libdebuginfod1t64 amd64 0.193-1 [21.3 kB] 64s Get:13 http://ftpmaster.internal/ubuntu questing/main amd64 libdw1t64 amd64 0.193-1 [283 kB] 64s Get:14 http://ftpmaster.internal/ubuntu questing/main amd64 libelf1t64 amd64 0.193-1 [58.6 kB] 64s Get:15 http://ftpmaster.internal/ubuntu questing/main amd64 python3-dbus amd64 1.4.0-1 [102 kB] 64s Get:16 http://ftpmaster.internal/ubuntu questing/main amd64 lto-disabled-list all 58 [12.4 kB] 65s Preconfiguring packages ... 66s Fetched 11.8 MB in 1s (11.7 MB/s) 66s (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 ... 80527 files and directories currently installed.) 66s Preparing to unpack .../libperl5.40_5.40.1-3_amd64.deb ... 66s Unpacking libperl5.40:amd64 (5.40.1-3) over (5.40.1-2) ... 66s Preparing to unpack .../perl_5.40.1-3_amd64.deb ... 66s Unpacking perl (5.40.1-3) over (5.40.1-2) ... 66s Preparing to unpack .../perl-base_5.40.1-3_amd64.deb ... 66s Unpacking perl-base (5.40.1-3) over (5.40.1-2) ... 66s Setting up perl-base (5.40.1-3) ... 66s (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 ... 80527 files and directories currently installed.) 66s Preparing to unpack .../perl-modules-5.40_5.40.1-3_all.deb ... 66s Unpacking perl-modules-5.40 (5.40.1-3) over (5.40.1-2) ... 67s Preparing to unpack .../libdebuginfod-common_0.193-1_all.deb ... 67s Unpacking libdebuginfod-common (0.193-1) over (0.192-4ubuntu1) ... 67s Preparing to unpack .../libatomic1_15.1.0-2ubuntu1_amd64.deb ... 67s Unpacking libatomic1:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 67s Preparing to unpack .../gcc-15-base_15.1.0-2ubuntu1_amd64.deb ... 67s Unpacking gcc-15-base:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 67s Setting up gcc-15-base:amd64 (15.1.0-2ubuntu1) ... 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 ... 80527 files and directories currently installed.) 67s Preparing to unpack .../libgcc-s1_15.1.0-2ubuntu1_amd64.deb ... 67s Unpacking libgcc-s1:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 67s Setting up libgcc-s1:amd64 (15.1.0-2ubuntu1) ... 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 ... 80527 files and directories currently installed.) 67s Preparing to unpack .../libstdc++6_15.1.0-2ubuntu1_amd64.deb ... 67s Unpacking libstdc++6:amd64 (15.1.0-2ubuntu1) over (15-20250404-0ubuntu1) ... 67s Setting up libstdc++6:amd64 (15.1.0-2ubuntu1) ... 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 ... 80527 files and directories currently installed.) 67s Preparing to unpack .../0-sensible-utils_0.0.25_all.deb ... 67s Unpacking sensible-utils (0.0.25) over (0.0.24) ... 67s Preparing to unpack .../1-ca-certificates_20250419_all.deb ... 67s Unpacking ca-certificates (20250419) over (20241223) ... 67s Preparing to unpack .../2-libdebuginfod1t64_0.193-1_amd64.deb ... 67s Unpacking libdebuginfod1t64:amd64 (0.193-1) over (0.192-4ubuntu1) ... 67s Preparing to unpack .../3-libdw1t64_0.193-1_amd64.deb ... 67s Unpacking libdw1t64:amd64 (0.193-1) over (0.192-4ubuntu1) ... 67s Preparing to unpack .../4-libelf1t64_0.193-1_amd64.deb ... 67s Unpacking libelf1t64:amd64 (0.193-1) over (0.192-4ubuntu1) ... 67s Preparing to unpack .../5-python3-dbus_1.4.0-1_amd64.deb ... 67s Unpacking python3-dbus (1.4.0-1) over (1.3.2-5build5) ... 67s Preparing to unpack .../6-lto-disabled-list_58_all.deb ... 67s Unpacking lto-disabled-list (58) over (57) ... 67s Setting up python3-dbus (1.4.0-1) ... 68s Setting up lto-disabled-list (58) ... 68s Setting up libdebuginfod-common (0.193-1) ... 68s Setting up libelf1t64:amd64 (0.193-1) ... 68s Setting up libdw1t64:amd64 (0.193-1) ... 68s Setting up ca-certificates (20250419) ... 70s Updating certificates in /etc/ssl/certs... 71s rehash: warning: skipping ca-certificates.crt, it does not contain exactly one certificate or CRL 71s 2 added, 4 removed; done. 71s Setting up libatomic1:amd64 (15.1.0-2ubuntu1) ... 71s Setting up perl-modules-5.40 (5.40.1-3) ... 71s Setting up sensible-utils (0.0.25) ... 71s Setting up libdebuginfod1t64:amd64 (0.193-1) ... 71s Setting up libperl5.40:amd64 (5.40.1-3) ... 71s Setting up perl (5.40.1-3) ... 71s Processing triggers for man-db (2.13.1-1) ... 72s Processing triggers for libc-bin (2.41-6ubuntu1) ... 72s Processing triggers for ca-certificates (20250419) ... 73s Updating certificates in /etc/ssl/certs... 73s 0 added, 0 removed; done. 73s Running hooks in /etc/ca-certificates/update.d... 73s done. 74s Reading package lists... 74s Building dependency tree... 74s Reading state information... 74s Starting pkgProblemResolver with broken count: 0 74s Starting 2 pkgProblemResolver with broken count: 0 74s Done 74s Solving dependencies... 75s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 77s autopkgtest [17:24:57]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Sun Apr 6 15:05:05 UTC 2025 77s autopkgtest [17:24:57]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 81s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 81s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 81s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 81s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 81s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 81s gpgv: issuer "rebecca_palmer@zoho.com" 81s gpgv: Can't check signature: No public key 81s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 82s autopkgtest [17:25:02]: testing package pandas version 2.2.3+dfsg-9 82s autopkgtest [17:25:02]: build not needed 85s autopkgtest [17:25:05]: test command1: preparing testbed 85s Reading package lists... 85s Building dependency tree... 85s Reading state information... 86s Starting pkgProblemResolver with broken count: 0 86s Starting 2 pkgProblemResolver with broken count: 0 86s Done 86s The following NEW packages will be installed: 86s libblas3 libgfortran5 liblapack3 python3-numpy python3-numpy-dev 86s python3-pandas python3-pandas-lib python3-pytz 86s 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. 86s Need to get 18.2 MB of archives. 86s After this operation, 90.8 MB of additional disk space will be used. 86s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy-dev amd64 1:2.2.4+ds-1 [147 kB] 87s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 libblas3 amd64 3.12.1-2 [359 kB] 87s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 libgfortran5 amd64 15.1.0-2ubuntu1 [924 kB] 87s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 liblapack3 amd64 3.12.1-2 [3179 kB] 87s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy amd64 1:2.2.4+ds-1 [5383 kB] 87s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-pytz all 2025.2-2 [163 kB] 87s Get:7 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pandas-lib amd64 2.2.3+dfsg-9 [4949 kB] 88s Get:8 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pandas all 2.2.3+dfsg-9 [3112 kB] 88s Fetched 18.2 MB in 2s (9407 kB/s) 88s Selecting previously unselected package python3-numpy-dev:amd64. 88s (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 ... 80525 files and directories currently installed.) 88s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_amd64.deb ... 88s Unpacking python3-numpy-dev:amd64 (1:2.2.4+ds-1) ... 89s Selecting previously unselected package libblas3:amd64. 89s Preparing to unpack .../1-libblas3_3.12.1-2_amd64.deb ... 89s Unpacking libblas3:amd64 (3.12.1-2) ... 89s Selecting previously unselected package libgfortran5:amd64. 89s Preparing to unpack .../2-libgfortran5_15.1.0-2ubuntu1_amd64.deb ... 89s Unpacking libgfortran5:amd64 (15.1.0-2ubuntu1) ... 89s Selecting previously unselected package liblapack3:amd64. 89s Preparing to unpack .../3-liblapack3_3.12.1-2_amd64.deb ... 89s Unpacking liblapack3:amd64 (3.12.1-2) ... 89s Selecting previously unselected package python3-numpy. 89s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_amd64.deb ... 89s Unpacking python3-numpy (1:2.2.4+ds-1) ... 89s Selecting previously unselected package python3-pytz. 89s Preparing to unpack .../5-python3-pytz_2025.2-2_all.deb ... 89s Unpacking python3-pytz (2025.2-2) ... 89s Selecting previously unselected package python3-pandas-lib:amd64. 89s Preparing to unpack .../6-python3-pandas-lib_2.2.3+dfsg-9_amd64.deb ... 89s Unpacking python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 89s Selecting previously unselected package python3-pandas. 89s Preparing to unpack .../7-python3-pandas_2.2.3+dfsg-9_all.deb ... 89s Unpacking python3-pandas (2.2.3+dfsg-9) ... 89s Setting up python3-pytz (2025.2-2) ... 89s Setting up libblas3:amd64 (3.12.1-2) ... 89s 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 89s Setting up python3-numpy-dev:amd64 (1:2.2.4+ds-1) ... 89s Setting up libgfortran5:amd64 (15.1.0-2ubuntu1) ... 89s Setting up liblapack3:amd64 (3.12.1-2) ... 89s 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 89s Setting up python3-numpy (1:2.2.4+ds-1) ... 91s Setting up python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 91s Setting up python3-pandas (2.2.3+dfsg-9) ... 94s Processing triggers for man-db (2.13.1-1) ... 94s Processing triggers for libc-bin (2.41-6ubuntu1) ... 95s autopkgtest [17:25:15]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 95s autopkgtest [17:25:15]: test command1: [----------------------- 96s autopkgtest [17:25:16]: test command1: -----------------------] 97s command1 PASS 97s autopkgtest [17:25:17]: test command1: - - - - - - - - - - results - - - - - - - - - - 97s autopkgtest [17:25:17]: test unittests3: preparing testbed 98s Reading package lists... 98s Building dependency tree... 98s Reading state information... 98s Starting pkgProblemResolver with broken count: 0 98s Starting 2 pkgProblemResolver with broken count: 0 98s Done 98s The following NEW packages will be installed: 98s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 98s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 98s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 98s libdrm-intel1 libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libgbm1 libgl1 98s libgl1-mesa-dri libglvnd0 libglx-mesa0 libglx0 libgomp1 libgraphite2-3 98s libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin libinput10 98s libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblbfgsb0 98s liblcms2-2 liblerc4 libmd4c0 libmtdev1t64 libopenjp2-7 libpciaccess0 98s libpcre2-16-0 libpixman-1-0 libqhull-r8.0 libqt5core5t64 libqt5dbus5t64 98s libqt5designer5 libqt5gui5t64 libqt5help5 libqt5network5t64 98s libqt5printsupport5t64 libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 98s libqt5xml5t64 libraqm0 libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 98s libtiff6 libtk8.6 libvulkan1 libwacom-common libwacom9 libwayland-client0 98s libwayland-server0 libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 98s libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 98s libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 98s libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 98s libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxfont2 libxft2 98s libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1 98s libxshmfence1 libxslt1.1 libxss1 libxt6t64 libxxf86vm1 locales-all 98s mesa-libgallium python-matplotlib-data python-tables-data python3-all 98s python3-async-generator python3-bottleneck python3-brotli python3-bs4 98s python3-click python3-cloudpickle python3-contourpy python3-cpuinfo 98s python3-cycler python3-dask python3-decorator python3-defusedxml 98s python3-et-xmlfile python3-execnet python3-fonttools python3-fs 98s python3-fsspec python3-greenlet python3-html5lib python3-hypothesis 98s python3-iniconfig python3-kiwisolver python3-locket python3-lxml python3-lz4 98s python3-matplotlib python3-mpmath python3-numexpr python3-odf 98s python3-openpyxl python3-partd python3-pil python3-pil.imagetk 98s python3-platformdirs python3-pluggy python3-py python3-pyqt5 98s python3-pyqt5.sip python3-pyreadstat python3-pytest python3-pytest-asyncio 98s python3-pytest-forked python3-pytest-localserver python3-pytest-xdist 98s python3-pytestqt python3-scipy python3-sortedcontainers python3-soupsieve 98s python3-sqlalchemy python3-sympy python3-tables python3-tables-lib 98s python3-tabulate python3-tk python3-toolz python3-tz python3-ufolib2 98s python3-webencodings python3-werkzeug python3-xarray python3-xlrd 98s python3-xlsxwriter python3-zstandard python3.13-tk tk8.6-blt2.5 98s tzdata-legacy unicode-data x11-common x11-xkb-utils xsel xserver-common xvfb 99s 0 upgraded, 185 newly installed, 0 to remove and 0 not upgraded. 99s Need to get 119 MB of archives. 99s After this operation, 675 MB of additional disk space will be used. 99s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 libtcl8.6 amd64 8.6.16+dfsg-1 [1086 kB] 99s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-mono all 2.37-8 [502 kB] 99s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-core all 2.37-8 [835 kB] 99s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig-config amd64 2.15.0-2.2ubuntu1 [37.8 kB] 99s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 libfontconfig1 amd64 2.15.0-2.2ubuntu1 [164 kB] 99s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 libxrender1 amd64 1:0.9.12-1 [19.8 kB] 99s Get:7 http://ftpmaster.internal/ubuntu questing/main amd64 libxft2 amd64 2.3.6-1build1 [45.3 kB] 99s Get:8 http://ftpmaster.internal/ubuntu questing/main amd64 x11-common all 1:7.7+23ubuntu4 [21.8 kB] 99s Get:9 http://ftpmaster.internal/ubuntu questing/main amd64 libxss1 amd64 1:1.2.3-1build3 [7204 B] 99s Get:10 http://ftpmaster.internal/ubuntu questing/main amd64 libtk8.6 amd64 8.6.16-1 [868 kB] 99s Get:11 http://ftpmaster.internal/ubuntu questing/main amd64 tk8.6-blt2.5 amd64 2.5.3+dfsg-8 [694 kB] 99s Get:12 http://ftpmaster.internal/ubuntu questing/main amd64 blt amd64 2.5.3+dfsg-8 [4824 B] 99s Get:13 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig amd64 2.15.0-2.2ubuntu1 [180 kB] 99s Get:14 http://ftpmaster.internal/ubuntu questing/universe amd64 fonts-lyx all 2.4.3-1 [171 kB] 99s Get:15 http://ftpmaster.internal/ubuntu questing/universe amd64 libaec0 amd64 1.1.3-1 [22.7 kB] 99s Get:16 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common-data amd64 0.8-16ubuntu2 [31.0 kB] 99s Get:17 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common3 amd64 0.8-16ubuntu2 [23.6 kB] 99s Get:18 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-client3 amd64 0.8-16ubuntu2 [27.5 kB] 99s Get:19 http://ftpmaster.internal/ubuntu questing/main amd64 libsnappy1v5 amd64 1.2.2-1 [30.9 kB] 99s Get:20 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc1 amd64 1.21.5+ds-1build1 [36.2 kB] 99s Get:21 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc2-4 amd64 2.17.1+ds-1 [171 kB] 99s Get:22 http://ftpmaster.internal/ubuntu questing/main amd64 libcups2t64 amd64 2.4.12-0ubuntu1 [292 kB] 99s Get:23 http://ftpmaster.internal/ubuntu questing/main amd64 libdeflate0 amd64 1.23-2 [49.9 kB] 99s Get:24 http://ftpmaster.internal/ubuntu questing/universe amd64 libdouble-conversion3 amd64 3.3.1-1 [41.7 kB] 99s Get:25 http://ftpmaster.internal/ubuntu questing/main amd64 libpciaccess0 amd64 0.17-3build1 [18.6 kB] 99s Get:26 http://ftpmaster.internal/ubuntu questing/main amd64 libdrm-intel1 amd64 2.4.124-2 [68.9 kB] 99s Get:27 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-server0 amd64 1.23.1-3 [37.2 kB] 99s Get:28 http://ftpmaster.internal/ubuntu questing/main amd64 libx11-xcb1 amd64 2:1.8.12-1 [7968 B] 99s Get:29 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-dri3-0 amd64 1.17.0-2 [7508 B] 100s Get:30 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-present0 amd64 1.17.0-2 [6064 B] 100s Get:31 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-randr0 amd64 1.17.0-2 [17.9 kB] 100s Get:32 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-sync1 amd64 1.17.0-2 [9312 B] 100s Get:33 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xfixes0 amd64 1.17.0-2 [10.2 kB] 100s Get:34 http://ftpmaster.internal/ubuntu questing/main amd64 libxshmfence1 amd64 1.3.3-1 [5262 B] 100s Get:35 http://ftpmaster.internal/ubuntu questing/main amd64 mesa-libgallium amd64 25.0.3-1ubuntu2 [12.1 MB] 100s Get:36 http://ftpmaster.internal/ubuntu questing/main amd64 libgbm1 amd64 25.0.3-1ubuntu2 [33.4 kB] 100s Get:37 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-client0 amd64 1.23.1-3 [29.7 kB] 100s Get:38 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shm0 amd64 1.17.0-2 [5758 B] 100s Get:39 http://ftpmaster.internal/ubuntu questing/main amd64 libegl-mesa0 amd64 25.0.3-1ubuntu2 [136 kB] 100s Get:40 http://ftpmaster.internal/ubuntu questing/main amd64 libfontenc1 amd64 1:1.1.8-1build1 [14.0 kB] 100s Get:41 http://ftpmaster.internal/ubuntu questing/main amd64 libvulkan1 amd64 1.4.309.0-1 [145 kB] 100s Get:42 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1-mesa-dri amd64 25.0.3-1ubuntu2 [35.7 kB] 100s Get:43 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-glx0 amd64 1.17.0-2 [24.8 kB] 100s Get:44 http://ftpmaster.internal/ubuntu questing/main amd64 libxxf86vm1 amd64 1:1.1.4-1build4 [9282 B] 100s Get:45 http://ftpmaster.internal/ubuntu questing/main amd64 libglx-mesa0 amd64 25.0.3-1ubuntu2 [146 kB] 100s Get:46 http://ftpmaster.internal/ubuntu questing/main amd64 libgomp1 amd64 15.1.0-2ubuntu1 [151 kB] 100s Get:47 http://ftpmaster.internal/ubuntu questing/main amd64 libgraphite2-3 amd64 1.3.14-2ubuntu1 [73.1 kB] 100s Get:48 http://ftpmaster.internal/ubuntu questing/main amd64 libharfbuzz0b amd64 10.2.0-1 [543 kB] 100s Get:49 http://ftpmaster.internal/ubuntu questing/universe amd64 libsz2 amd64 1.1.3-1 [5456 B] 100s Get:50 http://ftpmaster.internal/ubuntu questing/universe amd64 libhdf5-310 amd64 1.14.5+repack-3 [1519 kB] 100s Get:51 http://ftpmaster.internal/ubuntu questing/main amd64 libice6 amd64 2:1.1.1-1 [44.1 kB] 100s Get:52 http://ftpmaster.internal/ubuntu questing/main amd64 libimagequant0 amd64 2.18.0-1build1 [36.3 kB] 100s Get:53 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom-common all 2.14.0-1 [103 kB] 100s Get:54 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom9 amd64 2.14.0-1 [27.3 kB] 100s Get:55 http://ftpmaster.internal/ubuntu questing/main amd64 libinput-bin amd64 1.28.1-1 [23.6 kB] 100s Get:56 http://ftpmaster.internal/ubuntu questing/main amd64 libmtdev1t64 amd64 1.1.7-1 [16.3 kB] 100s Get:57 http://ftpmaster.internal/ubuntu questing/main amd64 libinput10 amd64 1.28.1-1 [144 kB] 100s Get:58 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg-turbo8 amd64 2.1.5-3ubuntu2 [179 kB] 101s Get:59 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg8 amd64 8c-2ubuntu11 [2148 B] 101s Get:60 http://ftpmaster.internal/ubuntu questing/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 101s Get:61 http://ftpmaster.internal/ubuntu questing/universe amd64 libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 101s Get:62 http://ftpmaster.internal/ubuntu questing/universe amd64 liblbfgsb0 amd64 3.0+dfsg.4-1build1 [29.9 kB] 101s Get:63 http://ftpmaster.internal/ubuntu questing/main amd64 liblcms2-2 amd64 2.16-2 [212 kB] 101s Get:64 http://ftpmaster.internal/ubuntu questing/main amd64 liblerc4 amd64 4.0.0+ds-5ubuntu1 [271 kB] 101s Get:65 http://ftpmaster.internal/ubuntu questing/universe amd64 libmd4c0 amd64 0.5.2-2 [50.1 kB] 101s Get:66 http://ftpmaster.internal/ubuntu questing/main amd64 libpcre2-16-0 amd64 10.45-1 [268 kB] 101s Get:67 http://ftpmaster.internal/ubuntu questing/main amd64 libpixman-1-0 amd64 0.44.0-3 [427 kB] 101s Get:68 http://ftpmaster.internal/ubuntu questing/universe amd64 libqhull-r8.0 amd64 2020.2-6build1 [193 kB] 101s Get:69 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5core5t64 amd64 5.15.15+dfsg-4ubuntu1 [2038 kB] 101s Get:70 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5dbus5t64 amd64 5.15.15+dfsg-4ubuntu1 [221 kB] 101s Get:71 http://ftpmaster.internal/ubuntu questing/main amd64 libglvnd0 amd64 1.7.0-1build1 [69.6 kB] 101s Get:72 http://ftpmaster.internal/ubuntu questing/main amd64 libegl1 amd64 1.7.0-1build1 [28.7 kB] 101s Get:73 http://ftpmaster.internal/ubuntu questing/main amd64 libglx0 amd64 1.7.0-1build1 [38.6 kB] 101s Get:74 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1 amd64 1.7.0-1build1 [102 kB] 101s Get:75 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5network5t64 amd64 5.15.15+dfsg-4ubuntu1 [725 kB] 101s Get:76 http://ftpmaster.internal/ubuntu questing/main amd64 libsm6 amd64 2:1.2.6-1 [16.4 kB] 101s Get:77 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-icccm4 amd64 0.4.2-1 [11.1 kB] 101s Get:78 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-util1 amd64 0.4.1-1 [11.2 kB] 101s Get:79 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-image0 amd64 0.4.0-2build1 [10.8 kB] 101s Get:80 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-keysyms1 amd64 0.4.1-1 [8738 B] 101s Get:81 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render0 amd64 1.17.0-2 [16.2 kB] 101s Get:82 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render-util0 amd64 0.3.10-1 [10.8 kB] 101s Get:83 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shape0 amd64 1.17.0-2 [6092 B] 101s Get:84 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinerama0 amd64 1.17.0-2 [5412 B] 101s Get:85 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinput0 amd64 1.17.0-2 [33.2 kB] 101s Get:86 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xkb1 amd64 1.17.0-2 [32.3 kB] 101s Get:87 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbcommon-x11-0 amd64 1.7.0-2 [15.2 kB] 101s Get:88 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5gui5t64 amd64 5.15.15+dfsg-4ubuntu1 [3791 kB] 101s Get:89 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5widgets5t64 amd64 5.15.15+dfsg-4ubuntu1 [2560 kB] 101s Get:90 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5xml5t64 amd64 5.15.15+dfsg-4ubuntu1 [124 kB] 101s Get:91 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5designer5 amd64 5.15.15-6build1 [2827 kB] 101s Get:92 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5sql5t64 amd64 5.15.15+dfsg-4ubuntu1 [122 kB] 101s Get:93 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5help5 amd64 5.15.15-6build1 [162 kB] 101s Get:94 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5printsupport5t64 amd64 5.15.15+dfsg-4ubuntu1 [208 kB] 101s Get:95 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5test5t64 amd64 5.15.15+dfsg-4ubuntu1 [149 kB] 101s Get:96 http://ftpmaster.internal/ubuntu questing/main amd64 libraqm0 amd64 0.10.2-1 [17.2 kB] 101s Get:97 http://ftpmaster.internal/ubuntu questing/main amd64 libsharpyuv0 amd64 1.5.0-0.1 [25.9 kB] 101s Get:98 http://ftpmaster.internal/ubuntu questing/main amd64 libjbig0 amd64 2.1-6.1ubuntu2 [29.7 kB] 101s Get:99 http://ftpmaster.internal/ubuntu questing/main amd64 libwebp7 amd64 1.5.0-0.1 [378 kB] 101s Get:100 http://ftpmaster.internal/ubuntu questing/main amd64 libtiff6 amd64 4.7.0-3ubuntu1 [204 kB] 101s Get:101 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpdemux2 amd64 1.5.0-0.1 [13.0 kB] 102s Get:102 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpmux3 amd64 1.5.0-0.1 [27.6 kB] 102s Get:103 http://ftpmaster.internal/ubuntu questing/main amd64 libxt6t64 amd64 1:1.2.1-1.2build1 [171 kB] 102s Get:104 http://ftpmaster.internal/ubuntu questing/main amd64 libxmu6 amd64 2:1.1.3-3build2 [47.6 kB] 102s Get:105 http://ftpmaster.internal/ubuntu questing/main amd64 libxpm4 amd64 1:3.5.17-1build2 [36.5 kB] 102s Get:106 http://ftpmaster.internal/ubuntu questing/main amd64 libxaw7 amd64 2:1.0.16-1 [207 kB] 102s Get:107 http://ftpmaster.internal/ubuntu questing/main amd64 libxfont2 amd64 1:2.0.6-1build1 [93.0 kB] 102s Get:108 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbfile1 amd64 1:1.1.0-1build4 [70.0 kB] 102s Get:109 http://ftpmaster.internal/ubuntu questing/main amd64 libxrandr2 amd64 2:1.5.4-1 [19.6 kB] 102s Get:110 http://ftpmaster.internal/ubuntu questing/main amd64 libxslt1.1 amd64 1.1.39-0exp1ubuntu4 [176 kB] 102s Get:111 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 102s Get:112 http://ftpmaster.internal/ubuntu questing/universe amd64 python-tables-data all 3.10.2-2build1 [49.7 kB] 102s Get:113 http://ftpmaster.internal/ubuntu questing/main amd64 python3-all amd64 3.13.3-1 [882 B] 102s Get:114 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-async-generator all 1.10-4 [17.5 kB] 102s Get:115 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-bottleneck amd64 1.4.2+ds1-2build1 [91.2 kB] 102s Get:116 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-brotli amd64 1.1.0-2build4 [367 kB] 102s Get:117 http://ftpmaster.internal/ubuntu questing/main amd64 python3-soupsieve all 2.7-1 [33.5 kB] 102s Get:118 http://ftpmaster.internal/ubuntu questing/main amd64 python3-bs4 all 4.13.4-1 [137 kB] 102s Get:119 http://ftpmaster.internal/ubuntu questing/main amd64 python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 102s Get:120 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cloudpickle all 3.1.1-1 [22.4 kB] 102s Get:121 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-contourpy amd64 1.3.1-1build1 [218 kB] 102s Get:122 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 102s Get:123 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cycler all 0.12.1-1 [9716 B] 102s Get:124 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fsspec all 2025.3.0-1 [216 kB] 102s Get:125 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-toolz all 1.0.0-2 [45.0 kB] 102s Get:126 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-locket all 1.0.0-2 [5872 B] 102s Get:127 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-partd all 1.4.2-1 [15.7 kB] 102s Get:128 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-dask all 2024.12.1+dfsg-2 [875 kB] 102s Get:129 http://ftpmaster.internal/ubuntu questing/main amd64 python3-decorator all 5.2.1-2 [28.1 kB] 102s Get:130 http://ftpmaster.internal/ubuntu questing/main amd64 python3-defusedxml all 0.7.1-3 [42.2 kB] 102s Get:131 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-et-xmlfile all 2.0.0-1 [79.4 kB] 102s Get:132 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-execnet all 2.1.1-1 [33.4 kB] 102s Get:133 http://ftpmaster.internal/ubuntu questing/main amd64 python3-platformdirs all 4.3.7-1 [16.9 kB] 102s Get:134 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fs all 2.4.16-7 [90.8 kB] 103s Get:135 http://ftpmaster.internal/ubuntu questing/main amd64 python3-lxml amd64 5.4.0-1 [1342 kB] 103s Get:136 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-lz4 amd64 4.4.0+dfsg-2 [26.6 kB] 103s Get:137 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-scipy amd64 1.14.1-4ubuntu2 [18.7 MB] 104s Get:138 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-mpmath all 1.3.0-1 [425 kB] 104s Get:139 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-sympy all 1.13.3-5 [4229 kB] 104s Get:140 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 104s Get:141 http://ftpmaster.internal/ubuntu questing/universe amd64 unicode-data all 15.1.0-1 [8878 kB] 104s Get:142 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fonttools amd64 4.55.3-2build1 [1536 kB] 104s Get:143 http://ftpmaster.internal/ubuntu questing/main amd64 python3-webencodings all 0.5.1-5 [11.5 kB] 104s Get:144 http://ftpmaster.internal/ubuntu questing/main amd64 python3-html5lib all 1.2-2 [90.6 kB] 104s Get:145 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sortedcontainers all 2.4.0-2 [27.6 kB] 104s Get:146 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-hypothesis all 6.130.5-1 [341 kB] 104s Get:147 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-iniconfig all 1.1.1-2 [6024 B] 104s Get:148 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-kiwisolver amd64 1.4.7-3build1 [55.6 kB] 104s Get:149 http://ftpmaster.internal/ubuntu questing/main amd64 libopenjp2-7 amd64 2.5.3-2 [218 kB] 104s Get:150 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pil amd64 11.1.0-5build1 [583 kB] 104s Get:151 http://ftpmaster.internal/ubuntu questing/main amd64 python3.13-tk amd64 3.13.3-1 [107 kB] 104s Get:152 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tk amd64 3.13.3-1 [9856 B] 104s Get:153 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pil.imagetk amd64 11.1.0-5build1 [9828 B] 104s Get:154 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 python3-matplotlib amd64 3.10.1+dfsg1-3 [18.1 MB] 105s Get:155 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-numexpr amd64 2.10.2-1build2 [131 kB] 105s Get:156 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-odf all 1.4.2-4 [79.0 kB] 105s Get:157 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 105s Get:158 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pluggy all 1.5.0-1 [21.0 kB] 105s Get:159 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-py all 1.11.0-4 [72.7 kB] 105s Get:160 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5.sip amd64 12.17.0-1build1 [76.5 kB] 105s Get:161 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5 amd64 5.15.11+dfsg-2 [2725 kB] 106s Get:162 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyreadstat amd64 1.2.8-1build1 [438 kB] 106s Get:163 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest all 8.3.5-1 [252 kB] 106s Get:164 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 106s Get:165 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-forked all 1.6.0-3 [7470 B] 106s Get:166 http://ftpmaster.internal/ubuntu questing/main amd64 python3-werkzeug all 3.1.3-2 [169 kB] 106s Get:167 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 106s Get:168 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-xdist all 3.6.1-1 [33.8 kB] 106s Get:169 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytestqt all 4.4.0-1 [32.4 kB] 106s Get:170 http://ftpmaster.internal/ubuntu questing/main amd64 python3-greenlet amd64 3.1.0-1build1 [166 kB] 106s Get:171 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 106s Get:172 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables-lib amd64 3.10.2-2build1 [588 kB] 106s Get:173 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables all 3.10.2-2build1 [354 kB] 106s Get:174 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tabulate all 0.9.0-1 [45.3 kB] 106s Get:175 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-tz all 2025.2-2 [1860 B] 106s Get:176 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xarray all 2025.01.2-1 [810 kB] 106s Get:177 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlrd all 2.0.1-2 [83.1 kB] 106s Get:178 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlsxwriter all 3.1.9-2 [462 kB] 106s Get:179 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-zstandard amd64 0.23.0-3build1 [431 kB] 106s Get:180 http://ftpmaster.internal/ubuntu questing/main amd64 tzdata-legacy all 2025b-1ubuntu1 [99.2 kB] 106s Get:181 http://ftpmaster.internal/ubuntu questing/main amd64 x11-xkb-utils amd64 7.7+9 [169 kB] 106s Get:182 http://ftpmaster.internal/ubuntu questing/universe amd64 xsel amd64 1.2.1-1 [20.5 kB] 106s Get:183 http://ftpmaster.internal/ubuntu questing/main amd64 xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 106s Get:184 http://ftpmaster.internal/ubuntu questing/universe amd64 xvfb amd64 2:21.1.16-1ubuntu1 [975 kB] 106s Get:185 http://ftpmaster.internal/ubuntu questing/universe amd64 locales-all amd64 2.41-6ubuntu1 [11.2 MB] 107s Fetched 119 MB in 8s (14.9 MB/s) 107s Selecting previously unselected package libtcl8.6:amd64. 107s (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 ... 83814 files and directories currently installed.) 107s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_amd64.deb ... 107s Unpacking libtcl8.6:amd64 (8.6.16+dfsg-1) ... 107s Selecting previously unselected package fonts-dejavu-mono. 107s Preparing to unpack .../001-fonts-dejavu-mono_2.37-8_all.deb ... 107s Unpacking fonts-dejavu-mono (2.37-8) ... 107s Selecting previously unselected package fonts-dejavu-core. 107s Preparing to unpack .../002-fonts-dejavu-core_2.37-8_all.deb ... 107s Unpacking fonts-dejavu-core (2.37-8) ... 107s Selecting previously unselected package fontconfig-config. 107s Preparing to unpack .../003-fontconfig-config_2.15.0-2.2ubuntu1_amd64.deb ... 107s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 107s Selecting previously unselected package libfontconfig1:amd64. 107s Preparing to unpack .../004-libfontconfig1_2.15.0-2.2ubuntu1_amd64.deb ... 107s Unpacking libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 107s Selecting previously unselected package libxrender1:amd64. 107s Preparing to unpack .../005-libxrender1_1%3a0.9.12-1_amd64.deb ... 107s Unpacking libxrender1:amd64 (1:0.9.12-1) ... 107s Selecting previously unselected package libxft2:amd64. 107s Preparing to unpack .../006-libxft2_2.3.6-1build1_amd64.deb ... 107s Unpacking libxft2:amd64 (2.3.6-1build1) ... 107s Selecting previously unselected package x11-common. 107s Preparing to unpack .../007-x11-common_1%3a7.7+23ubuntu4_all.deb ... 107s Unpacking x11-common (1:7.7+23ubuntu4) ... 107s Selecting previously unselected package libxss1:amd64. 108s Preparing to unpack .../008-libxss1_1%3a1.2.3-1build3_amd64.deb ... 108s Unpacking libxss1:amd64 (1:1.2.3-1build3) ... 108s Selecting previously unselected package libtk8.6:amd64. 108s Preparing to unpack .../009-libtk8.6_8.6.16-1_amd64.deb ... 108s Unpacking libtk8.6:amd64 (8.6.16-1) ... 108s Selecting previously unselected package tk8.6-blt2.5. 108s Preparing to unpack .../010-tk8.6-blt2.5_2.5.3+dfsg-8_amd64.deb ... 108s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 108s Selecting previously unselected package blt. 108s Preparing to unpack .../011-blt_2.5.3+dfsg-8_amd64.deb ... 108s Unpacking blt (2.5.3+dfsg-8) ... 108s Selecting previously unselected package fontconfig. 108s Preparing to unpack .../012-fontconfig_2.15.0-2.2ubuntu1_amd64.deb ... 108s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 108s Selecting previously unselected package fonts-lyx. 108s Preparing to unpack .../013-fonts-lyx_2.4.3-1_all.deb ... 108s Unpacking fonts-lyx (2.4.3-1) ... 108s Selecting previously unselected package libaec0:amd64. 108s Preparing to unpack .../014-libaec0_1.1.3-1_amd64.deb ... 108s Unpacking libaec0:amd64 (1.1.3-1) ... 108s Selecting previously unselected package libavahi-common-data:amd64. 108s Preparing to unpack .../015-libavahi-common-data_0.8-16ubuntu2_amd64.deb ... 108s Unpacking libavahi-common-data:amd64 (0.8-16ubuntu2) ... 108s Selecting previously unselected package libavahi-common3:amd64. 108s Preparing to unpack .../016-libavahi-common3_0.8-16ubuntu2_amd64.deb ... 108s Unpacking libavahi-common3:amd64 (0.8-16ubuntu2) ... 108s Selecting previously unselected package libavahi-client3:amd64. 108s Preparing to unpack .../017-libavahi-client3_0.8-16ubuntu2_amd64.deb ... 108s Unpacking libavahi-client3:amd64 (0.8-16ubuntu2) ... 108s Selecting previously unselected package libsnappy1v5:amd64. 108s Preparing to unpack .../018-libsnappy1v5_1.2.2-1_amd64.deb ... 108s Unpacking libsnappy1v5:amd64 (1.2.2-1) ... 108s Selecting previously unselected package libblosc1:amd64. 108s Preparing to unpack .../019-libblosc1_1.21.5+ds-1build1_amd64.deb ... 108s Unpacking libblosc1:amd64 (1.21.5+ds-1build1) ... 108s Selecting previously unselected package libblosc2-4:amd64. 108s Preparing to unpack .../020-libblosc2-4_2.17.1+ds-1_amd64.deb ... 108s Unpacking libblosc2-4:amd64 (2.17.1+ds-1) ... 108s Selecting previously unselected package libcups2t64:amd64. 108s Preparing to unpack .../021-libcups2t64_2.4.12-0ubuntu1_amd64.deb ... 108s Unpacking libcups2t64:amd64 (2.4.12-0ubuntu1) ... 108s Selecting previously unselected package libdeflate0:amd64. 108s Preparing to unpack .../022-libdeflate0_1.23-2_amd64.deb ... 108s Unpacking libdeflate0:amd64 (1.23-2) ... 108s Selecting previously unselected package libdouble-conversion3:amd64. 108s Preparing to unpack .../023-libdouble-conversion3_3.3.1-1_amd64.deb ... 108s Unpacking libdouble-conversion3:amd64 (3.3.1-1) ... 108s Selecting previously unselected package libpciaccess0:amd64. 108s Preparing to unpack .../024-libpciaccess0_0.17-3build1_amd64.deb ... 108s Unpacking libpciaccess0:amd64 (0.17-3build1) ... 108s Selecting previously unselected package libdrm-intel1:amd64. 108s Preparing to unpack .../025-libdrm-intel1_2.4.124-2_amd64.deb ... 108s Unpacking libdrm-intel1:amd64 (2.4.124-2) ... 108s Selecting previously unselected package libwayland-server0:amd64. 108s Preparing to unpack .../026-libwayland-server0_1.23.1-3_amd64.deb ... 108s Unpacking libwayland-server0:amd64 (1.23.1-3) ... 108s Selecting previously unselected package libx11-xcb1:amd64. 108s Preparing to unpack .../027-libx11-xcb1_2%3a1.8.12-1_amd64.deb ... 108s Unpacking libx11-xcb1:amd64 (2:1.8.12-1) ... 108s Selecting previously unselected package libxcb-dri3-0:amd64. 108s Preparing to unpack .../028-libxcb-dri3-0_1.17.0-2_amd64.deb ... 108s Unpacking libxcb-dri3-0:amd64 (1.17.0-2) ... 108s Selecting previously unselected package libxcb-present0:amd64. 108s Preparing to unpack .../029-libxcb-present0_1.17.0-2_amd64.deb ... 108s Unpacking libxcb-present0:amd64 (1.17.0-2) ... 108s Selecting previously unselected package libxcb-randr0:amd64. 108s Preparing to unpack .../030-libxcb-randr0_1.17.0-2_amd64.deb ... 108s Unpacking libxcb-randr0:amd64 (1.17.0-2) ... 108s Selecting previously unselected package libxcb-sync1:amd64. 108s Preparing to unpack .../031-libxcb-sync1_1.17.0-2_amd64.deb ... 108s Unpacking libxcb-sync1:amd64 (1.17.0-2) ... 108s Selecting previously unselected package libxcb-xfixes0:amd64. 108s Preparing to unpack .../032-libxcb-xfixes0_1.17.0-2_amd64.deb ... 108s Unpacking libxcb-xfixes0:amd64 (1.17.0-2) ... 108s Selecting previously unselected package libxshmfence1:amd64. 108s Preparing to unpack .../033-libxshmfence1_1.3.3-1_amd64.deb ... 108s Unpacking libxshmfence1:amd64 (1.3.3-1) ... 108s Selecting previously unselected package mesa-libgallium:amd64. 108s Preparing to unpack .../034-mesa-libgallium_25.0.3-1ubuntu2_amd64.deb ... 108s Unpacking mesa-libgallium:amd64 (25.0.3-1ubuntu2) ... 109s Selecting previously unselected package libgbm1:amd64. 109s Preparing to unpack .../035-libgbm1_25.0.3-1ubuntu2_amd64.deb ... 109s Unpacking libgbm1:amd64 (25.0.3-1ubuntu2) ... 109s Selecting previously unselected package libwayland-client0:amd64. 109s Preparing to unpack .../036-libwayland-client0_1.23.1-3_amd64.deb ... 109s Unpacking libwayland-client0:amd64 (1.23.1-3) ... 109s Selecting previously unselected package libxcb-shm0:amd64. 109s Preparing to unpack .../037-libxcb-shm0_1.17.0-2_amd64.deb ... 109s Unpacking libxcb-shm0:amd64 (1.17.0-2) ... 109s Selecting previously unselected package libegl-mesa0:amd64. 109s Preparing to unpack .../038-libegl-mesa0_25.0.3-1ubuntu2_amd64.deb ... 109s Unpacking libegl-mesa0:amd64 (25.0.3-1ubuntu2) ... 109s Selecting previously unselected package libfontenc1:amd64. 109s Preparing to unpack .../039-libfontenc1_1%3a1.1.8-1build1_amd64.deb ... 109s Unpacking libfontenc1:amd64 (1:1.1.8-1build1) ... 109s Selecting previously unselected package libvulkan1:amd64. 109s Preparing to unpack .../040-libvulkan1_1.4.309.0-1_amd64.deb ... 109s Unpacking libvulkan1:amd64 (1.4.309.0-1) ... 109s Selecting previously unselected package libgl1-mesa-dri:amd64. 109s Preparing to unpack .../041-libgl1-mesa-dri_25.0.3-1ubuntu2_amd64.deb ... 109s Unpacking libgl1-mesa-dri:amd64 (25.0.3-1ubuntu2) ... 109s Selecting previously unselected package libxcb-glx0:amd64. 109s Preparing to unpack .../042-libxcb-glx0_1.17.0-2_amd64.deb ... 109s Unpacking libxcb-glx0:amd64 (1.17.0-2) ... 109s Selecting previously unselected package libxxf86vm1:amd64. 109s Preparing to unpack .../043-libxxf86vm1_1%3a1.1.4-1build4_amd64.deb ... 109s Unpacking libxxf86vm1:amd64 (1:1.1.4-1build4) ... 109s Selecting previously unselected package libglx-mesa0:amd64. 109s Preparing to unpack .../044-libglx-mesa0_25.0.3-1ubuntu2_amd64.deb ... 109s Unpacking libglx-mesa0:amd64 (25.0.3-1ubuntu2) ... 109s Selecting previously unselected package libgomp1:amd64. 109s Preparing to unpack .../045-libgomp1_15.1.0-2ubuntu1_amd64.deb ... 109s Unpacking libgomp1:amd64 (15.1.0-2ubuntu1) ... 109s Selecting previously unselected package libgraphite2-3:amd64. 109s Preparing to unpack .../046-libgraphite2-3_1.3.14-2ubuntu1_amd64.deb ... 109s Unpacking libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 109s Selecting previously unselected package libharfbuzz0b:amd64. 109s Preparing to unpack .../047-libharfbuzz0b_10.2.0-1_amd64.deb ... 109s Unpacking libharfbuzz0b:amd64 (10.2.0-1) ... 109s Selecting previously unselected package libsz2:amd64. 109s Preparing to unpack .../048-libsz2_1.1.3-1_amd64.deb ... 109s Unpacking libsz2:amd64 (1.1.3-1) ... 109s Selecting previously unselected package libhdf5-310:amd64. 109s Preparing to unpack .../049-libhdf5-310_1.14.5+repack-3_amd64.deb ... 109s Unpacking libhdf5-310:amd64 (1.14.5+repack-3) ... 109s Selecting previously unselected package libice6:amd64. 109s Preparing to unpack .../050-libice6_2%3a1.1.1-1_amd64.deb ... 109s Unpacking libice6:amd64 (2:1.1.1-1) ... 109s Selecting previously unselected package libimagequant0:amd64. 109s Preparing to unpack .../051-libimagequant0_2.18.0-1build1_amd64.deb ... 109s Unpacking libimagequant0:amd64 (2.18.0-1build1) ... 109s Selecting previously unselected package libwacom-common. 109s Preparing to unpack .../052-libwacom-common_2.14.0-1_all.deb ... 109s Unpacking libwacom-common (2.14.0-1) ... 109s Selecting previously unselected package libwacom9:amd64. 109s Preparing to unpack .../053-libwacom9_2.14.0-1_amd64.deb ... 109s Unpacking libwacom9:amd64 (2.14.0-1) ... 109s Selecting previously unselected package libinput-bin. 109s Preparing to unpack .../054-libinput-bin_1.28.1-1_amd64.deb ... 109s Unpacking libinput-bin (1.28.1-1) ... 109s Selecting previously unselected package libmtdev1t64:amd64. 109s Preparing to unpack .../055-libmtdev1t64_1.1.7-1_amd64.deb ... 109s Unpacking libmtdev1t64:amd64 (1.1.7-1) ... 109s Selecting previously unselected package libinput10:amd64. 109s Preparing to unpack .../056-libinput10_1.28.1-1_amd64.deb ... 109s Unpacking libinput10:amd64 (1.28.1-1) ... 109s Selecting previously unselected package libjpeg-turbo8:amd64. 109s Preparing to unpack .../057-libjpeg-turbo8_2.1.5-3ubuntu2_amd64.deb ... 109s Unpacking libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 109s Selecting previously unselected package libjpeg8:amd64. 109s Preparing to unpack .../058-libjpeg8_8c-2ubuntu11_amd64.deb ... 109s Unpacking libjpeg8:amd64 (8c-2ubuntu11) ... 109s Selecting previously unselected package libjs-jquery. 109s Preparing to unpack .../059-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 109s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 109s Selecting previously unselected package libjs-jquery-ui. 109s Preparing to unpack .../060-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 109s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 109s Selecting previously unselected package liblbfgsb0:amd64. 109s Preparing to unpack .../061-liblbfgsb0_3.0+dfsg.4-1build1_amd64.deb ... 109s Unpacking liblbfgsb0:amd64 (3.0+dfsg.4-1build1) ... 109s Selecting previously unselected package liblcms2-2:amd64. 109s Preparing to unpack .../062-liblcms2-2_2.16-2_amd64.deb ... 109s Unpacking liblcms2-2:amd64 (2.16-2) ... 109s Selecting previously unselected package liblerc4:amd64. 109s Preparing to unpack .../063-liblerc4_4.0.0+ds-5ubuntu1_amd64.deb ... 109s Unpacking liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 109s Selecting previously unselected package libmd4c0:amd64. 109s Preparing to unpack .../064-libmd4c0_0.5.2-2_amd64.deb ... 110s Unpacking libmd4c0:amd64 (0.5.2-2) ... 110s Selecting previously unselected package libpcre2-16-0:amd64. 110s Preparing to unpack .../065-libpcre2-16-0_10.45-1_amd64.deb ... 110s Unpacking libpcre2-16-0:amd64 (10.45-1) ... 110s Selecting previously unselected package libpixman-1-0:amd64. 110s Preparing to unpack .../066-libpixman-1-0_0.44.0-3_amd64.deb ... 110s Unpacking libpixman-1-0:amd64 (0.44.0-3) ... 110s Selecting previously unselected package libqhull-r8.0:amd64. 110s Preparing to unpack .../067-libqhull-r8.0_2020.2-6build1_amd64.deb ... 110s Unpacking libqhull-r8.0:amd64 (2020.2-6build1) ... 110s Selecting previously unselected package libqt5core5t64:amd64. 110s Preparing to unpack .../068-libqt5core5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5core5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 110s Selecting previously unselected package libqt5dbus5t64:amd64. 110s Preparing to unpack .../069-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5dbus5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 110s Selecting previously unselected package libglvnd0:amd64. 110s Preparing to unpack .../070-libglvnd0_1.7.0-1build1_amd64.deb ... 110s Unpacking libglvnd0:amd64 (1.7.0-1build1) ... 110s Selecting previously unselected package libegl1:amd64. 110s Preparing to unpack .../071-libegl1_1.7.0-1build1_amd64.deb ... 110s Unpacking libegl1:amd64 (1.7.0-1build1) ... 110s Selecting previously unselected package libglx0:amd64. 110s Preparing to unpack .../072-libglx0_1.7.0-1build1_amd64.deb ... 110s Unpacking libglx0:amd64 (1.7.0-1build1) ... 110s Selecting previously unselected package libgl1:amd64. 110s Preparing to unpack .../073-libgl1_1.7.0-1build1_amd64.deb ... 110s Unpacking libgl1:amd64 (1.7.0-1build1) ... 110s Selecting previously unselected package libqt5network5t64:amd64. 110s Preparing to unpack .../074-libqt5network5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5network5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 110s Selecting previously unselected package libsm6:amd64. 110s Preparing to unpack .../075-libsm6_2%3a1.2.6-1_amd64.deb ... 110s Unpacking libsm6:amd64 (2:1.2.6-1) ... 110s Selecting previously unselected package libxcb-icccm4:amd64. 110s Preparing to unpack .../076-libxcb-icccm4_0.4.2-1_amd64.deb ... 110s Unpacking libxcb-icccm4:amd64 (0.4.2-1) ... 110s Selecting previously unselected package libxcb-util1:amd64. 110s Preparing to unpack .../077-libxcb-util1_0.4.1-1_amd64.deb ... 110s Unpacking libxcb-util1:amd64 (0.4.1-1) ... 110s Selecting previously unselected package libxcb-image0:amd64. 110s Preparing to unpack .../078-libxcb-image0_0.4.0-2build1_amd64.deb ... 110s Unpacking libxcb-image0:amd64 (0.4.0-2build1) ... 110s Selecting previously unselected package libxcb-keysyms1:amd64. 110s Preparing to unpack .../079-libxcb-keysyms1_0.4.1-1_amd64.deb ... 110s Unpacking libxcb-keysyms1:amd64 (0.4.1-1) ... 110s Selecting previously unselected package libxcb-render0:amd64. 110s Preparing to unpack .../080-libxcb-render0_1.17.0-2_amd64.deb ... 110s Unpacking libxcb-render0:amd64 (1.17.0-2) ... 110s Selecting previously unselected package libxcb-render-util0:amd64. 110s Preparing to unpack .../081-libxcb-render-util0_0.3.10-1_amd64.deb ... 110s Unpacking libxcb-render-util0:amd64 (0.3.10-1) ... 110s Selecting previously unselected package libxcb-shape0:amd64. 110s Preparing to unpack .../082-libxcb-shape0_1.17.0-2_amd64.deb ... 110s Unpacking libxcb-shape0:amd64 (1.17.0-2) ... 110s Selecting previously unselected package libxcb-xinerama0:amd64. 110s Preparing to unpack .../083-libxcb-xinerama0_1.17.0-2_amd64.deb ... 110s Unpacking libxcb-xinerama0:amd64 (1.17.0-2) ... 110s Selecting previously unselected package libxcb-xinput0:amd64. 110s Preparing to unpack .../084-libxcb-xinput0_1.17.0-2_amd64.deb ... 110s Unpacking libxcb-xinput0:amd64 (1.17.0-2) ... 110s Selecting previously unselected package libxcb-xkb1:amd64. 110s Preparing to unpack .../085-libxcb-xkb1_1.17.0-2_amd64.deb ... 110s Unpacking libxcb-xkb1:amd64 (1.17.0-2) ... 110s Selecting previously unselected package libxkbcommon-x11-0:amd64. 110s Preparing to unpack .../086-libxkbcommon-x11-0_1.7.0-2_amd64.deb ... 110s Unpacking libxkbcommon-x11-0:amd64 (1.7.0-2) ... 110s Selecting previously unselected package libqt5gui5t64:amd64. 110s Preparing to unpack .../087-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5gui5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 110s Selecting previously unselected package libqt5widgets5t64:amd64. 110s Preparing to unpack .../088-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5widgets5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 110s Selecting previously unselected package libqt5xml5t64:amd64. 110s Preparing to unpack .../089-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 110s Unpacking libqt5xml5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 111s Selecting previously unselected package libqt5designer5:amd64. 111s Preparing to unpack .../090-libqt5designer5_5.15.15-6build1_amd64.deb ... 111s Unpacking libqt5designer5:amd64 (5.15.15-6build1) ... 111s Selecting previously unselected package libqt5sql5t64:amd64. 111s Preparing to unpack .../091-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 111s Unpacking libqt5sql5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 111s Selecting previously unselected package libqt5help5:amd64. 111s Preparing to unpack .../092-libqt5help5_5.15.15-6build1_amd64.deb ... 111s Unpacking libqt5help5:amd64 (5.15.15-6build1) ... 111s Selecting previously unselected package libqt5printsupport5t64:amd64. 111s Preparing to unpack .../093-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 111s Unpacking libqt5printsupport5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 111s Selecting previously unselected package libqt5test5t64:amd64. 111s Preparing to unpack .../094-libqt5test5t64_5.15.15+dfsg-4ubuntu1_amd64.deb ... 111s Unpacking libqt5test5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 111s Selecting previously unselected package libraqm0:amd64. 111s Preparing to unpack .../095-libraqm0_0.10.2-1_amd64.deb ... 111s Unpacking libraqm0:amd64 (0.10.2-1) ... 111s Selecting previously unselected package libsharpyuv0:amd64. 111s Preparing to unpack .../096-libsharpyuv0_1.5.0-0.1_amd64.deb ... 111s Unpacking libsharpyuv0:amd64 (1.5.0-0.1) ... 111s Selecting previously unselected package libjbig0:amd64. 111s Preparing to unpack .../097-libjbig0_2.1-6.1ubuntu2_amd64.deb ... 111s Unpacking libjbig0:amd64 (2.1-6.1ubuntu2) ... 111s Selecting previously unselected package libwebp7:amd64. 111s Preparing to unpack .../098-libwebp7_1.5.0-0.1_amd64.deb ... 111s Unpacking libwebp7:amd64 (1.5.0-0.1) ... 111s Selecting previously unselected package libtiff6:amd64. 111s Preparing to unpack .../099-libtiff6_4.7.0-3ubuntu1_amd64.deb ... 111s Unpacking libtiff6:amd64 (4.7.0-3ubuntu1) ... 111s Selecting previously unselected package libwebpdemux2:amd64. 111s Preparing to unpack .../100-libwebpdemux2_1.5.0-0.1_amd64.deb ... 111s Unpacking libwebpdemux2:amd64 (1.5.0-0.1) ... 111s Selecting previously unselected package libwebpmux3:amd64. 111s Preparing to unpack .../101-libwebpmux3_1.5.0-0.1_amd64.deb ... 111s Unpacking libwebpmux3:amd64 (1.5.0-0.1) ... 111s Selecting previously unselected package libxt6t64:amd64. 111s Preparing to unpack .../102-libxt6t64_1%3a1.2.1-1.2build1_amd64.deb ... 111s Unpacking libxt6t64:amd64 (1:1.2.1-1.2build1) ... 111s Selecting previously unselected package libxmu6:amd64. 111s Preparing to unpack .../103-libxmu6_2%3a1.1.3-3build2_amd64.deb ... 111s Unpacking libxmu6:amd64 (2:1.1.3-3build2) ... 111s Selecting previously unselected package libxpm4:amd64. 111s Preparing to unpack .../104-libxpm4_1%3a3.5.17-1build2_amd64.deb ... 111s Unpacking libxpm4:amd64 (1:3.5.17-1build2) ... 111s Selecting previously unselected package libxaw7:amd64. 111s Preparing to unpack .../105-libxaw7_2%3a1.0.16-1_amd64.deb ... 111s Unpacking libxaw7:amd64 (2:1.0.16-1) ... 111s Selecting previously unselected package libxfont2:amd64. 111s Preparing to unpack .../106-libxfont2_1%3a2.0.6-1build1_amd64.deb ... 111s Unpacking libxfont2:amd64 (1:2.0.6-1build1) ... 111s Selecting previously unselected package libxkbfile1:amd64. 111s Preparing to unpack .../107-libxkbfile1_1%3a1.1.0-1build4_amd64.deb ... 111s Unpacking libxkbfile1:amd64 (1:1.1.0-1build4) ... 111s Selecting previously unselected package libxrandr2:amd64. 111s Preparing to unpack .../108-libxrandr2_2%3a1.5.4-1_amd64.deb ... 111s Unpacking libxrandr2:amd64 (2:1.5.4-1) ... 111s Selecting previously unselected package libxslt1.1:amd64. 111s Preparing to unpack .../109-libxslt1.1_1.1.39-0exp1ubuntu4_amd64.deb ... 111s Unpacking libxslt1.1:amd64 (1.1.39-0exp1ubuntu4) ... 111s Selecting previously unselected package python-matplotlib-data. 111s Preparing to unpack .../110-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 111s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 111s Selecting previously unselected package python-tables-data. 111s Preparing to unpack .../111-python-tables-data_3.10.2-2build1_all.deb ... 111s Unpacking python-tables-data (3.10.2-2build1) ... 111s Selecting previously unselected package python3-all. 111s Preparing to unpack .../112-python3-all_3.13.3-1_amd64.deb ... 111s Unpacking python3-all (3.13.3-1) ... 111s Selecting previously unselected package python3-async-generator. 111s Preparing to unpack .../113-python3-async-generator_1.10-4_all.deb ... 111s Unpacking python3-async-generator (1.10-4) ... 111s Selecting previously unselected package python3-bottleneck. 111s Preparing to unpack .../114-python3-bottleneck_1.4.2+ds1-2build1_amd64.deb ... 111s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 111s Selecting previously unselected package python3-brotli. 111s Preparing to unpack .../115-python3-brotli_1.1.0-2build4_amd64.deb ... 111s Unpacking python3-brotli (1.1.0-2build4) ... 111s Selecting previously unselected package python3-soupsieve. 111s Preparing to unpack .../116-python3-soupsieve_2.7-1_all.deb ... 111s Unpacking python3-soupsieve (2.7-1) ... 111s Selecting previously unselected package python3-bs4. 111s Preparing to unpack .../117-python3-bs4_4.13.4-1_all.deb ... 111s Unpacking python3-bs4 (4.13.4-1) ... 112s Selecting previously unselected package python3-click. 112s Preparing to unpack .../118-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 112s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 112s Selecting previously unselected package python3-cloudpickle. 112s Preparing to unpack .../119-python3-cloudpickle_3.1.1-1_all.deb ... 112s Unpacking python3-cloudpickle (3.1.1-1) ... 112s Selecting previously unselected package python3-contourpy. 112s Preparing to unpack .../120-python3-contourpy_1.3.1-1build1_amd64.deb ... 112s Unpacking python3-contourpy (1.3.1-1build1) ... 112s Selecting previously unselected package python3-cpuinfo. 112s Preparing to unpack .../121-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 112s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 112s Selecting previously unselected package python3-cycler. 112s Preparing to unpack .../122-python3-cycler_0.12.1-1_all.deb ... 112s Unpacking python3-cycler (0.12.1-1) ... 112s Selecting previously unselected package python3-fsspec. 112s Preparing to unpack .../123-python3-fsspec_2025.3.0-1_all.deb ... 112s Unpacking python3-fsspec (2025.3.0-1) ... 112s Selecting previously unselected package python3-toolz. 112s Preparing to unpack .../124-python3-toolz_1.0.0-2_all.deb ... 112s Unpacking python3-toolz (1.0.0-2) ... 112s Selecting previously unselected package python3-locket. 112s Preparing to unpack .../125-python3-locket_1.0.0-2_all.deb ... 112s Unpacking python3-locket (1.0.0-2) ... 112s Selecting previously unselected package python3-partd. 112s Preparing to unpack .../126-python3-partd_1.4.2-1_all.deb ... 112s Unpacking python3-partd (1.4.2-1) ... 112s Selecting previously unselected package python3-dask. 112s Preparing to unpack .../127-python3-dask_2024.12.1+dfsg-2_all.deb ... 112s Unpacking python3-dask (2024.12.1+dfsg-2) ... 112s Selecting previously unselected package python3-decorator. 112s Preparing to unpack .../128-python3-decorator_5.2.1-2_all.deb ... 112s Unpacking python3-decorator (5.2.1-2) ... 112s Selecting previously unselected package python3-defusedxml. 112s Preparing to unpack .../129-python3-defusedxml_0.7.1-3_all.deb ... 112s Unpacking python3-defusedxml (0.7.1-3) ... 112s Selecting previously unselected package python3-et-xmlfile. 112s Preparing to unpack .../130-python3-et-xmlfile_2.0.0-1_all.deb ... 112s Unpacking python3-et-xmlfile (2.0.0-1) ... 112s Selecting previously unselected package python3-execnet. 112s Preparing to unpack .../131-python3-execnet_2.1.1-1_all.deb ... 112s Unpacking python3-execnet (2.1.1-1) ... 112s Selecting previously unselected package python3-platformdirs. 112s Preparing to unpack .../132-python3-platformdirs_4.3.7-1_all.deb ... 112s Unpacking python3-platformdirs (4.3.7-1) ... 112s Selecting previously unselected package python3-fs. 112s Preparing to unpack .../133-python3-fs_2.4.16-7_all.deb ... 112s Unpacking python3-fs (2.4.16-7) ... 112s Selecting previously unselected package python3-lxml:amd64. 112s Preparing to unpack .../134-python3-lxml_5.4.0-1_amd64.deb ... 112s Unpacking python3-lxml:amd64 (5.4.0-1) ... 112s Selecting previously unselected package python3-lz4. 112s Preparing to unpack .../135-python3-lz4_4.4.0+dfsg-2_amd64.deb ... 112s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 112s Selecting previously unselected package python3-scipy. 112s Preparing to unpack .../136-python3-scipy_1.14.1-4ubuntu2_amd64.deb ... 112s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 113s Selecting previously unselected package python3-mpmath. 113s Preparing to unpack .../137-python3-mpmath_1.3.0-1_all.deb ... 113s Unpacking python3-mpmath (1.3.0-1) ... 113s Selecting previously unselected package python3-sympy. 113s Preparing to unpack .../138-python3-sympy_1.13.3-5_all.deb ... 113s Unpacking python3-sympy (1.13.3-5) ... 113s Selecting previously unselected package python3-ufolib2. 113s Preparing to unpack .../139-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 113s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 113s Selecting previously unselected package unicode-data. 113s Preparing to unpack .../140-unicode-data_15.1.0-1_all.deb ... 113s Unpacking unicode-data (15.1.0-1) ... 113s Selecting previously unselected package python3-fonttools. 113s Preparing to unpack .../141-python3-fonttools_4.55.3-2build1_amd64.deb ... 113s Unpacking python3-fonttools (4.55.3-2build1) ... 113s Selecting previously unselected package python3-webencodings. 113s Preparing to unpack .../142-python3-webencodings_0.5.1-5_all.deb ... 113s Unpacking python3-webencodings (0.5.1-5) ... 113s Selecting previously unselected package python3-html5lib. 113s Preparing to unpack .../143-python3-html5lib_1.2-2_all.deb ... 113s Unpacking python3-html5lib (1.2-2) ... 113s Selecting previously unselected package python3-sortedcontainers. 113s Preparing to unpack .../144-python3-sortedcontainers_2.4.0-2_all.deb ... 113s Unpacking python3-sortedcontainers (2.4.0-2) ... 113s Selecting previously unselected package python3-hypothesis. 113s Preparing to unpack .../145-python3-hypothesis_6.130.5-1_all.deb ... 113s Unpacking python3-hypothesis (6.130.5-1) ... 113s Selecting previously unselected package python3-iniconfig. 113s Preparing to unpack .../146-python3-iniconfig_1.1.1-2_all.deb ... 113s Unpacking python3-iniconfig (1.1.1-2) ... 113s Selecting previously unselected package python3-kiwisolver. 113s Preparing to unpack .../147-python3-kiwisolver_1.4.7-3build1_amd64.deb ... 113s Unpacking python3-kiwisolver (1.4.7-3build1) ... 113s Selecting previously unselected package libopenjp2-7:amd64. 113s Preparing to unpack .../148-libopenjp2-7_2.5.3-2_amd64.deb ... 113s Unpacking libopenjp2-7:amd64 (2.5.3-2) ... 114s Selecting previously unselected package python3-pil:amd64. 114s Preparing to unpack .../149-python3-pil_11.1.0-5build1_amd64.deb ... 114s Unpacking python3-pil:amd64 (11.1.0-5build1) ... 114s Selecting previously unselected package python3.13-tk. 114s Preparing to unpack .../150-python3.13-tk_3.13.3-1_amd64.deb ... 114s Unpacking python3.13-tk (3.13.3-1) ... 114s Selecting previously unselected package python3-tk:amd64. 114s Preparing to unpack .../151-python3-tk_3.13.3-1_amd64.deb ... 114s Unpacking python3-tk:amd64 (3.13.3-1) ... 114s Selecting previously unselected package python3-pil.imagetk:amd64. 114s Preparing to unpack .../152-python3-pil.imagetk_11.1.0-5build1_amd64.deb ... 114s Unpacking python3-pil.imagetk:amd64 (11.1.0-5build1) ... 114s Selecting previously unselected package python3-matplotlib. 114s Preparing to unpack .../153-python3-matplotlib_3.10.1+dfsg1-3_amd64.deb ... 114s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 114s Selecting previously unselected package python3-numexpr. 114s Preparing to unpack .../154-python3-numexpr_2.10.2-1build2_amd64.deb ... 114s Unpacking python3-numexpr (2.10.2-1build2) ... 114s Selecting previously unselected package python3-odf. 114s Preparing to unpack .../155-python3-odf_1.4.2-4_all.deb ... 114s Unpacking python3-odf (1.4.2-4) ... 114s Selecting previously unselected package python3-openpyxl. 114s Preparing to unpack .../156-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 114s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 114s Selecting previously unselected package python3-pluggy. 114s Preparing to unpack .../157-python3-pluggy_1.5.0-1_all.deb ... 114s Unpacking python3-pluggy (1.5.0-1) ... 114s Selecting previously unselected package python3-py. 114s Preparing to unpack .../158-python3-py_1.11.0-4_all.deb ... 114s Unpacking python3-py (1.11.0-4) ... 114s Selecting previously unselected package python3-pyqt5.sip. 114s Preparing to unpack .../159-python3-pyqt5.sip_12.17.0-1build1_amd64.deb ... 114s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 114s Selecting previously unselected package python3-pyqt5. 114s Preparing to unpack .../160-python3-pyqt5_5.15.11+dfsg-2_amd64.deb ... 114s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 114s Selecting previously unselected package python3-pyreadstat. 114s Preparing to unpack .../161-python3-pyreadstat_1.2.8-1build1_amd64.deb ... 114s Unpacking python3-pyreadstat (1.2.8-1build1) ... 114s Selecting previously unselected package python3-pytest. 114s Preparing to unpack .../162-python3-pytest_8.3.5-1_all.deb ... 114s Unpacking python3-pytest (8.3.5-1) ... 115s Selecting previously unselected package python3-pytest-asyncio. 115s Preparing to unpack .../163-python3-pytest-asyncio_0.25.1-1_all.deb ... 115s Unpacking python3-pytest-asyncio (0.25.1-1) ... 115s Selecting previously unselected package python3-pytest-forked. 115s Preparing to unpack .../164-python3-pytest-forked_1.6.0-3_all.deb ... 115s Unpacking python3-pytest-forked (1.6.0-3) ... 115s Selecting previously unselected package python3-werkzeug. 115s Preparing to unpack .../165-python3-werkzeug_3.1.3-2_all.deb ... 115s Unpacking python3-werkzeug (3.1.3-2) ... 115s Selecting previously unselected package python3-pytest-localserver. 115s Preparing to unpack .../166-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 115s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 115s Selecting previously unselected package python3-pytest-xdist. 115s Preparing to unpack .../167-python3-pytest-xdist_3.6.1-1_all.deb ... 115s Unpacking python3-pytest-xdist (3.6.1-1) ... 115s Selecting previously unselected package python3-pytestqt. 115s Preparing to unpack .../168-python3-pytestqt_4.4.0-1_all.deb ... 115s Unpacking python3-pytestqt (4.4.0-1) ... 115s Selecting previously unselected package python3-greenlet. 115s Preparing to unpack .../169-python3-greenlet_3.1.0-1build1_amd64.deb ... 115s Unpacking python3-greenlet (3.1.0-1build1) ... 115s Selecting previously unselected package python3-sqlalchemy. 115s Preparing to unpack .../170-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 115s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 115s Selecting previously unselected package python3-tables-lib. 115s Preparing to unpack .../171-python3-tables-lib_3.10.2-2build1_amd64.deb ... 115s Unpacking python3-tables-lib (3.10.2-2build1) ... 115s Selecting previously unselected package python3-tables. 115s Preparing to unpack .../172-python3-tables_3.10.2-2build1_all.deb ... 115s Unpacking python3-tables (3.10.2-2build1) ... 115s Selecting previously unselected package python3-tabulate. 115s Preparing to unpack .../173-python3-tabulate_0.9.0-1_all.deb ... 115s Unpacking python3-tabulate (0.9.0-1) ... 115s Selecting previously unselected package python3-tz. 115s Preparing to unpack .../174-python3-tz_2025.2-2_all.deb ... 115s Unpacking python3-tz (2025.2-2) ... 115s Selecting previously unselected package python3-xarray. 115s Preparing to unpack .../175-python3-xarray_2025.01.2-1_all.deb ... 115s Unpacking python3-xarray (2025.01.2-1) ... 115s Selecting previously unselected package python3-xlrd. 115s Preparing to unpack .../176-python3-xlrd_2.0.1-2_all.deb ... 115s Unpacking python3-xlrd (2.0.1-2) ... 115s Selecting previously unselected package python3-xlsxwriter. 115s Preparing to unpack .../177-python3-xlsxwriter_3.1.9-2_all.deb ... 115s Unpacking python3-xlsxwriter (3.1.9-2) ... 115s Selecting previously unselected package python3-zstandard. 115s Preparing to unpack .../178-python3-zstandard_0.23.0-3build1_amd64.deb ... 115s Unpacking python3-zstandard (0.23.0-3build1) ... 115s Selecting previously unselected package tzdata-legacy. 115s Preparing to unpack .../179-tzdata-legacy_2025b-1ubuntu1_all.deb ... 115s Unpacking tzdata-legacy (2025b-1ubuntu1) ... 115s Selecting previously unselected package x11-xkb-utils. 115s Preparing to unpack .../180-x11-xkb-utils_7.7+9_amd64.deb ... 115s Unpacking x11-xkb-utils (7.7+9) ... 115s Selecting previously unselected package xsel. 115s Preparing to unpack .../181-xsel_1.2.1-1_amd64.deb ... 115s Unpacking xsel (1.2.1-1) ... 115s Selecting previously unselected package xserver-common. 115s Preparing to unpack .../182-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 115s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 115s Selecting previously unselected package xvfb. 115s Preparing to unpack .../183-xvfb_2%3a21.1.16-1ubuntu1_amd64.deb ... 115s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 115s Selecting previously unselected package locales-all. 115s Preparing to unpack .../184-locales-all_2.41-6ubuntu1_amd64.deb ... 115s Unpacking locales-all (2.41-6ubuntu1) ... 117s Setting up libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 117s Setting up xsel (1.2.1-1) ... 117s Setting up libxcb-dri3-0:amd64 (1.17.0-2) ... 117s Setting up liblcms2-2:amd64 (2.16-2) ... 117s Setting up python3-iniconfig (1.1.1-2) ... 117s Setting up libpixman-1-0:amd64 (0.44.0-3) ... 117s Setting up libsharpyuv0:amd64 (1.5.0-0.1) ... 117s Setting up libwayland-server0:amd64 (1.23.1-3) ... 117s Setting up libx11-xcb1:amd64 (2:1.8.12-1) ... 117s Setting up libpciaccess0:amd64 (0.17-3build1) ... 117s Setting up libdouble-conversion3:amd64 (3.3.1-1) ... 117s Setting up libxcb-xfixes0:amd64 (1.17.0-2) ... 117s Setting up liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 117s Setting up libxpm4:amd64 (1:3.5.17-1build2) ... 117s Setting up python3-async-generator (1.10-4) ... 117s Setting up libxcb-xinput0:amd64 (1.17.0-2) ... 117s Setting up libxrender1:amd64 (1:0.9.12-1) ... 117s Setting up python3-py (1.11.0-4) ... 117s Setting up python3-lz4 (4.4.0+dfsg-2) ... 117s Setting up libxcb-render0:amd64 (1.17.0-2) ... 117s Setting up python3-defusedxml (0.7.1-3) ... 117s Setting up libglvnd0:amd64 (1.7.0-1build1) ... 117s Setting up fonts-lyx (2.4.3-1) ... 117s Setting up libxcb-glx0:amd64 (1.17.0-2) ... 117s Setting up python3-fsspec (2025.3.0-1) ... 117s Setting up python3-xarray (2025.01.2-1) ... 118s Setting up libdrm-intel1:amd64 (2.4.124-2) ... 118s Setting up libxcb-keysyms1:amd64 (0.4.1-1) ... 118s Setting up libxcb-shape0:amd64 (1.17.0-2) ... 118s Setting up x11-common (1:7.7+23ubuntu4) ... 119s Setting up libdeflate0:amd64 (1.23-2) ... 119s Setting up python3-tabulate (0.9.0-1) ... 119s Setting up libqhull-r8.0:amd64 (2020.2-6build1) ... 119s Setting up libxcb-render-util0:amd64 (0.3.10-1) ... 119s Setting up python3-all (3.13.3-1) ... 119s Setting up libxcb-shm0:amd64 (1.17.0-2) ... 119s Setting up libxcb-icccm4:amd64 (0.4.2-1) ... 119s Setting up python3-sortedcontainers (2.4.0-2) ... 119s Setting up libgomp1:amd64 (15.1.0-2ubuntu1) ... 119s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 119s Setting up libjbig0:amd64 (2.1-6.1ubuntu2) ... 119s Setting up python3-webencodings (0.5.1-5) ... 119s Setting up python3-pyreadstat (1.2.8-1build1) ... 119s Setting up locales-all (2.41-6ubuntu1) ... 119s Setting up libpcre2-16-0:amd64 (10.45-1) ... 119s Setting up libaec0:amd64 (1.1.3-1) ... 119s Setting up python3-platformdirs (4.3.7-1) ... 119s Setting up tzdata-legacy (2025b-1ubuntu1) ... 119s Setting up python3-tz (2025.2-2) ... 119s Setting up libxcb-util1:amd64 (0.4.1-1) ... 119s Setting up libxxf86vm1:amd64 (1:1.1.4-1build4) ... 119s Setting up python3-cloudpickle (3.1.1-1) ... 120s Setting up libsnappy1v5:amd64 (1.2.2-1) ... 120s Setting up libxcb-xkb1:amd64 (1.17.0-2) ... 120s Setting up libxcb-image0:amd64 (0.4.0-2build1) ... 120s Setting up python3-fs (2.4.16-7) ... 120s Setting up libxcb-present0:amd64 (1.17.0-2) ... 120s Setting up unicode-data (15.1.0-1) ... 120s Setting up libqt5core5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 120s Setting up python3-decorator (5.2.1-2) ... 120s Setting up libblosc2-4:amd64 (2.17.1+ds-1) ... 120s Setting up libfontenc1:amd64 (1:1.1.8-1build1) ... 120s Setting up python3-zstandard (0.23.0-3build1) ... 120s Setting up libxcb-xinerama0:amd64 (1.17.0-2) ... 120s Setting up python3-xlsxwriter (3.1.9-2) ... 120s Setting up libxcb-sync1:amd64 (1.17.0-2) ... 120s Setting up python3-werkzeug (3.1.3-2) ... 120s Setting up python3-brotli (1.1.0-2build4) ... 120s Setting up libavahi-common-data:amd64 (0.8-16ubuntu2) ... 120s Setting up python3-greenlet (3.1.0-1build1) ... 121s Setting up python3-cycler (0.12.1-1) ... 121s Setting up libimagequant0:amd64 (2.18.0-1build1) ... 121s Setting up libxkbcommon-x11-0:amd64 (1.7.0-2) ... 121s Setting up fonts-dejavu-mono (2.37-8) ... 121s Setting up python3-kiwisolver (1.4.7-3build1) ... 121s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 121s Setting up libxrandr2:amd64 (2:1.5.4-1) ... 121s Setting up libtcl8.6:amd64 (8.6.16+dfsg-1) ... 121s Setting up fonts-dejavu-core (2.37-8) ... 121s Setting up python3-numexpr (2.10.2-1build2) ... 121s Setting up libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 121s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 121s Setting up python3-html5lib (1.2-2) ... 121s Setting up libvulkan1:amd64 (1.4.309.0-1) ... 121s Setting up python3-pluggy (1.5.0-1) ... 121s Setting up libwebp7:amd64 (1.5.0-0.1) ... 121s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 121s Setting up libmtdev1t64:amd64 (1.1.7-1) ... 121s Setting up libxshmfence1:amd64 (1.3.3-1) ... 121s Setting up libxcb-randr0:amd64 (1.17.0-2) ... 121s Setting up libxslt1.1:amd64 (1.1.39-0exp1ubuntu4) ... 121s Setting up libblosc1:amd64 (1.21.5+ds-1build1) ... 121s Setting up python3-et-xmlfile (2.0.0-1) ... 122s Setting up libqt5sql5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 122s Setting up libmd4c0:amd64 (0.5.2-2) ... 122s Setting up python3-xlrd (2.0.1-2) ... 122s Setting up libopenjp2-7:amd64 (2.5.3-2) ... 122s Setting up python3-toolz (1.0.0-2) ... 122s Setting up libharfbuzz0b:amd64 (10.2.0-1) ... 122s Setting up python3-contourpy (1.3.1-1build1) ... 122s Setting up libxss1:amd64 (1:1.2.3-1build3) ... 122s Setting up libxkbfile1:amd64 (1:1.1.0-1build4) ... 122s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 122s Setting up python3-mpmath (1.3.0-1) ... 122s Setting up python3-execnet (2.1.1-1) ... 123s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 123s Setting up libwebpmux3:amd64 (1.5.0-0.1) ... 123s Setting up python3-locket (1.0.0-2) ... 123s Setting up libxfont2:amd64 (1:2.0.6-1build1) ... 123s Setting up python3-soupsieve (2.7-1) ... 123s Setting up python-tables-data (3.10.2-2build1) ... 123s Setting up libsz2:amd64 (1.1.3-1) ... 123s Setting up liblbfgsb0:amd64 (3.0+dfsg.4-1build1) ... 123s Setting up python3-odf (1.4.2-4) ... 123s Setting up libwacom-common (2.14.0-1) ... 123s Setting up libwayland-client0:amd64 (1.23.1-3) ... 123s Setting up libjpeg8:amd64 (8c-2ubuntu11) ... 123s Setting up python3-partd (1.4.2-1) ... 123s Setting up python3-sympy (1.13.3-5) ... 127s Setting up libice6:amd64 (2:1.1.1-1) ... 127s Setting up mesa-libgallium:amd64 (25.0.3-1ubuntu2) ... 127s Setting up libqt5dbus5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 127s Setting up python3-scipy (1.14.1-4ubuntu2) ... 130s Setting up libgbm1:amd64 (25.0.3-1ubuntu2) ... 130s Setting up libwacom9:amd64 (2.14.0-1) ... 130s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 130s Setting up python3-pytest (8.3.5-1) ... 130s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 130s Setting up libwebpdemux2:amd64 (1.5.0-0.1) ... 130s Setting up python3-hypothesis (6.130.5-1) ... 131s Setting up libgl1-mesa-dri:amd64 (25.0.3-1ubuntu2) ... 131s Setting up libqt5network5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 131s Setting up libavahi-common3:amd64 (0.8-16ubuntu2) ... 131s Setting up python3-dask (2024.12.1+dfsg-2) ... 132s Setting up libqt5xml5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 132s Setting up libqt5test5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 132s Setting up python3-bs4 (4.13.4-1) ... 132s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 133s Setting up libinput-bin (1.28.1-1) ... 133s Setting up python3-pytest-forked (1.6.0-3) ... 133s Setting up libegl-mesa0:amd64 (25.0.3-1ubuntu2) ... 133s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 133s Setting up libraqm0:amd64 (0.10.2-1) ... 133s Setting up python3-pytest-asyncio (0.25.1-1) ... 133s Setting up libhdf5-310:amd64 (1.14.5+repack-3) ... 133s Setting up python3-lxml:amd64 (5.4.0-1) ... 133s Setting up libtiff6:amd64 (4.7.0-3ubuntu1) ... 133s Setting up libegl1:amd64 (1.7.0-1build1) ... 133s Setting up libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 133s Setting up libsm6:amd64 (2:1.2.6-1) ... 133s Setting up python3-pytestqt (4.4.0-1) ... 133s Setting up libavahi-client3:amd64 (0.8-16ubuntu2) ... 133s Setting up libinput10:amd64 (1.28.1-1) ... 133s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 135s Regenerating fonts cache... done. 135s Setting up libxft2:amd64 (2.3.6-1build1) ... 135s Setting up libglx-mesa0:amd64 (25.0.3-1ubuntu2) ... 135s Setting up python3-pytest-xdist (3.6.1-1) ... 135s Setting up libglx0:amd64 (1.7.0-1build1) ... 135s Setting up python3-tables-lib (3.10.2-2build1) ... 135s Setting up libtk8.6:amd64 (8.6.16-1) ... 135s Setting up python3-tables (3.10.2-2build1) ... 136s Setting up python3.13-tk (3.13.3-1) ... 136s Setting up python3-pil:amd64 (11.1.0-5build1) ... 136s Setting up libgl1:amd64 (1.7.0-1build1) ... 136s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 136s Setting up libxt6t64:amd64 (1:1.2.1-1.2build1) ... 136s Setting up libcups2t64:amd64 (2.4.12-0ubuntu1) ... 136s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 136s Setting up libxmu6:amd64 (2:1.1.3-3build2) ... 136s Setting up blt (2.5.3+dfsg-8) ... 136s Setting up python3-tk:amd64 (3.13.3-1) ... 136s Setting up libxaw7:amd64 (2:1.0.16-1) ... 136s Setting up libqt5gui5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 136s Setting up python3-pil.imagetk:amd64 (11.1.0-5build1) ... 136s Setting up libqt5widgets5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 136s Setting up x11-xkb-utils (7.7+9) ... 136s Setting up libqt5help5:amd64 (5.15.15-6build1) ... 136s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 136s Setting up libqt5printsupport5t64:amd64 (5.15.15+dfsg-4ubuntu1) ... 136s Setting up libqt5designer5:amd64 (5.15.15-6build1) ... 136s Setting up xvfb (2:21.1.16-1ubuntu1) ... 136s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 136s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 137s Setting up python3-fonttools (4.55.3-2build1) ... 137s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 138s Processing triggers for libc-bin (2.41-6ubuntu1) ... 138s Processing triggers for man-db (2.13.1-1) ... 139s Processing triggers for udev (257.4-1ubuntu3) ... 140s autopkgtest [17:26:00]: test unittests3: [----------------------- 140s ++ dpkg --print-architecture 140s + arch=amd64 140s ++ py3versions -s 140s + pys=python3.13 140s + sourcetestroot=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests 140s + tomlfile=/tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 140s + echo amd64 i386 140s + grep amd64 140s ++ dpkg-vendor --query vendor 140s === python3.13 === 140s + '[' Debian = Ubuntu ']' 140s + marker='not slow' 140s + echo amd64 140s + grep -E 'mips|hppa' 140s + PYTEST_WARN_IGNORE= 140s + cd /tmp/autopkgtest.bEGXx0/autopkgtest_tmp 140s + TEST_SUCCESS=true 140s + for py in $pys 140s + echo '=== python3.13 ===' 140s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 141s + modpath=/usr/lib/python3/dist-packages/pandas 141s + for TEST_SUBSET in $modpath/tests/* 141s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 141s + grep -q -e __pycache__ 141s + PANDAS_CI=1 141s + LC_ALL=C.UTF-8 141s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 141s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 141s 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" 141s 141s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 142s ============================= test session starts ============================== 142s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 142s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 142s rootdir: /usr/lib/python3/dist-packages/pandas 142s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 142s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 142s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 142s collected 0 items 142s 142s =============================== warnings summary =============================== 142s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 142s /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-3jj_bi47' 142s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 142s 142s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 142s /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-rrqt2otq' 142s session.config.cache.set(STEPWISE_CACHE_DIR, []) 142s 142s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 142s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 142s ============================= 2 warnings in 0.12s ============================== 142s rdjoqkol test state = true 142s + test 5 == 5 142s + echo 'rdjoqkol test state = true' 142s + for TEST_SUBSET in $modpath/tests/* 142s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 142s + grep -q -e __pycache__ 142s rdjoqkol test state = true 142s + echo 'rdjoqkol test state = true' 142s + for TEST_SUBSET in $modpath/tests/* 142s + echo /usr/lib/python3/dist-packages/pandas/tests/api 142s + grep -q -e __pycache__ 142s + PANDAS_CI=1 142s + LC_ALL=C.UTF-8 142s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 142s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 142s 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" 142s 142s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 142s ============================= test session starts ============================== 142s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 142s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 142s rootdir: /usr/lib/python3/dist-packages/pandas 142s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 142s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 142s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 142s collected 14 items 142s 143s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 143s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 143s 143s =============================== warnings summary =============================== 143s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 143s /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-k60bq6wj' 143s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 143s 143s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 143s /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-80oxc_ky' 143s session.config.cache.set(STEPWISE_CACHE_DIR, []) 143s 143s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 143s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 143s ============================= slowest 30 durations ============================= 143s 143s (30 durations < 0.005s hidden. Use -vv to show these durations.) 143s ======================== 14 passed, 2 warnings in 0.11s ======================== 143s + echo 'rdjoqkol test state = true' 143s + for TEST_SUBSET in $modpath/tests/* 143s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 143s + grep -q -e __pycache__ 143s rdjoqkol test state = true 143s + PANDAS_CI=1 143s + LC_ALL=C.UTF-8 143s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 143s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 143s 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" 143s 143s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 143s ============================= test session starts ============================== 143s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 143s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 143s rootdir: /usr/lib/python3/dist-packages/pandas 143s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 143s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 143s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 143s collected 1243 items 143s 144s ../../../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....... 144s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 145s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 145s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 145s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 146s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 146s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 146s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 148s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 148s 148s =============================== warnings summary =============================== 148s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 148s /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-05s43cug' 148s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 148s 148s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 148s /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-rksesb3q' 148s session.config.cache.set(STEPWISE_CACHE_DIR, []) 148s 148s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 148s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 148s ============================= slowest 30 durations ============================= 148s 0.04s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 148s 0.03s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 148s 0.03s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 148s 0.02s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 148s 0.02s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 148s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 148s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 148s 0.01s call tests/apply/test_series_apply.py::test_transform[False] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 148s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 148s 0.01s call tests/apply/test_series_apply.py::test_transform[compat] 148s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 148s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 148s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 148s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 148s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 148s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 148s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 148s 0.01s call tests/apply/test_frame_apply.py::test_apply_mutating 148s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 148s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 148s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 148s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 148s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_multi_columns_multi_methods 148s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-fillna] 148s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='index'-pct_change] 148s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 5.09s =========== 148s + echo 'rdjoqkol test state = true' 148s + for TEST_SUBSET in $modpath/tests/* 148s rdjoqkol test state = true 148s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 148s + grep -q -e __pycache__ 148s + PANDAS_CI=1 148s + LC_ALL=C.UTF-8 148s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 149s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 149s 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" 149s 149s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 151s ============================= test session starts ============================== 151s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 151s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 151s rootdir: /usr/lib/python3/dist-packages/pandas 151s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 151s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 151s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 151s collected 19330 items 151s 151s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 151s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 208s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_datetime64.py .....................................................................................................................................................................................................................................................................................................................................................................+ echo 'rdjoqkol test state = true' 208s + for TEST_SUBSET in $modpath/tests/* 208s ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s..s................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 208s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 208s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 208s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 208s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 208s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 208s 208s =============================== warnings summary =============================== 208s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 208s /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-_c9lpm3v' 208s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 208s 208s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 208s /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-ia18zkd4' 208s session.config.cache.set(STEPWISE_CACHE_DIR, []) 208s 208s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 208s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 208s ============================= slowest 30 durations ============================= 208s 0.24s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_offset_arraylike[zoneinfo.ZoneInfo(key='US/Pacific')-names3-series-add] 208s 0.15s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[tzutc()-timedelta64_1-DataFrame] 208s 0.08s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 208s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 208s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 208s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 208s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 208s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-True-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthBegin] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-s-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Index-US/Central-us-5-False-cls_and_kwargs27] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthBegin] 208s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-CBMonthBegin] 208s =============== 19158 passed, 172 skipped, 2 warnings in 54.54s ================ 208s rdjoqkol test state = true 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 + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 208s + grep -q -e __pycache__ 208s + PANDAS_CI=1 208s + LC_ALL=C.UTF-8 208s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 208s ============================= test session starts ============================== 208s platform linux -- Python 3.13.3, 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.bEGXx0/build.t5V/src/pyproject.toml 208s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 208s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 208s collected 19230 items / 2 skipped 208s 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 210s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 211s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 212s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 213s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 213s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 213s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 214s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 214s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 214s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 214s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 215s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 215s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 215s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 215s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 215s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 217s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 218s ../../../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 218s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 218s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 234s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 238s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 238s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 238s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 239s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 239s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 239s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 239s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 239s 239s =============================== warnings summary =============================== 239s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 239s /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-zn4h32dk' 239s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 239s 239s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 239s /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-2da_cn2z' 239s session.config.cache.set(STEPWISE_CACHE_DIR, []) 239s 239s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 239s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 239s ============================= slowest 30 durations ============================= 239s 0.30s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 239s 0.21s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 239s 0.17s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 239s 0.10s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 239s 0.09s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 239s 0.03s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 239s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 239s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 239s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 239s 0.01s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[B] 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[D] 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[QE] 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[YE] 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[W] 239s 0.01s call tests/arrays/test_datetimelike.py::TestPeriodArray::test_median[ME] 239s 0.01s call tests/arrays/integer/test_arithmetic.py::test_reduce_to_float[mean] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-coo] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csc] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csr] 239s 0.01s call tests/arrays/categorical/test_api.py::TestCategoricalAPIWithFactor::test_describe 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-csc] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csr] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[int64-labels1-csc] 239s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-coo] 239s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 33.15s ========== 240s + echo 'rdjoqkol test state = true' 240s + for TEST_SUBSET in $modpath/tests/* 240s + echo /usr/lib/python3/dist-packages/pandas/tests/base 240s + grep -q -e __pycache__ 240s rdjoqkol test state = true 241s + PANDAS_CI=1 241s + LC_ALL=C.UTF-8 241s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 241s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 241s 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" 241s 241s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 241s ============================= test session starts ============================== 241s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 241s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 241s rootdir: /usr/lib/python3/dist-packages/pandas 241s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 241s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 241s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 241s collected 1775 items 241s 242s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 242s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 242s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 243s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 243s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 244s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 244s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 244s 244s =============================== warnings summary =============================== 244s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 244s /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-_hmkx7pv' 244s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 244s 244s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 244s /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-e2o6_t4l' 244s session.config.cache.set(STEPWISE_CACHE_DIR, []) 244s 244s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 244s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 244s ============================= slowest 30 durations ============================= 244s 0.05s setup tests/base/test_misc.py::test_memory_usage[datetime] 244s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 244s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 244s 0.02s call tests/base/test_value_counts.py::test_value_counts[interval] 244s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[index] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[series] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 244s 0.01s call tests/base/test_unique.py::test_unique[datetime-tz] 244s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 244s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 244s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 244s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 244s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 244s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 244s 0.01s call tests/base/test_unique.py::test_unique[datetime] 244s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 244s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[string-python-nan] 244s 0.01s call tests/base/test_value_counts.py::test_value_counts_datetime64[series-ns] 244s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 3.15s =========== 245s + echo 'rdjoqkol test state = true' 245s rdjoqkol test state = true 245s + for TEST_SUBSET in $modpath/tests/* 245s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 245s + grep -q -e __pycache__ 245s + PANDAS_CI=1 245s + LC_ALL=C.UTF-8 245s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 245s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 245s 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" 245s 245s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 246s ============================= test session starts ============================== 246s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 246s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 246s rootdir: /usr/lib/python3/dist-packages/pandas 246s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 246s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 246s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 246s collected 11159 items 246s 246s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 291s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 291s 291s =============================== warnings summary =============================== 291s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 291s /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-whmninh6' 291s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 291s 291s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 291s /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-pmsf_0px' 291s session.config.cache.set(STEPWISE_CACHE_DIR, []) 291s 291s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 291s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 291s ============================= slowest 30 durations ============================= 291s 0.19s teardown tests/computation/test_eval.py::TestEval::test_floor_division[DataFrame-SeriesNaN-numexpr-python] 291s 0.09s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-python-and-lt-ge] 291s 0.05s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 291s 0.04s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 291s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 291s 0.03s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 291s 0.03s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-dt] 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-i-i] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-s1] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-i-dt-dt-i] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-s-i] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-i-s0] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-i-s-dt] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-s-i-dt] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-s-s1] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-i-s1] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-s-s0] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-s-dt] 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_attr_expression 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-dt-i-s0] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-s-s-dt] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-pandas-i-dt-dt-s0] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-pandas-i-dt-dt-i] 291s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 291s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[numexpr-python-dt-s-i-i] 291s ========== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 45.32s =========== 292s rdjoqkol test state = true 292s + echo 'rdjoqkol test state = true' 292s + for TEST_SUBSET in $modpath/tests/* 292s + echo /usr/lib/python3/dist-packages/pandas/tests/config 292s + grep -q -e __pycache__ 292s + PANDAS_CI=1 292s + LC_ALL=C.UTF-8 292s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 292s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 292s 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" 292s 292s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 293s ============================= test session starts ============================== 293s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 293s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 293s rootdir: /usr/lib/python3/dist-packages/pandas 293s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 293s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 293s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 293s collected 50 items 293s 293s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 293s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 293s 293s =============================== warnings summary =============================== 293s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 293s /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-xb9qd4a5' 293s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 293s 293s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 293s /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-6z25kmem' 293s session.config.cache.set(STEPWISE_CACHE_DIR, []) 293s 293s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 293s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 293s ============================= slowest 30 durations ============================= 293s 0.01s call tests/config/test_localization.py::test_get_locales_prefix 293s 293s (29 durations < 0.005s hidden. Use -vv to show these durations.) 293s ======================== 50 passed, 2 warnings in 0.52s ======================== 293s rdjoqkol test state = true 293s + echo 'rdjoqkol test state = true' 293s + for TEST_SUBSET in $modpath/tests/* 293s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 293s + grep -q -e __pycache__ 293s + PANDAS_CI=1 293s + LC_ALL=C.UTF-8 293s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 294s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 294s 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" 294s 294s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 294s ============================= test session starts ============================== 294s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 294s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 294s rootdir: /usr/lib/python3/dist-packages/pandas 294s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 294s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 294s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 294s collected 1 item 294s 294s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 294s 294s =============================== warnings summary =============================== 294s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 294s /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-aytmcs9z' 294s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 294s 294s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 294s /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-tdxfd492' 294s session.config.cache.set(STEPWISE_CACHE_DIR, []) 294s 294s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 294s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 294s ============================= slowest 30 durations ============================= 294s 294s (3 durations < 0.005s hidden. Use -vv to show these durations.) 294s ======================== 1 passed, 2 warnings in 0.12s ========================= 294s rdjoqkol test state = true 294s + echo 'rdjoqkol test state = true' 294s + for TEST_SUBSET in $modpath/tests/* 294s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 294s + grep -q -e __pycache__ 294s + PANDAS_CI=1 294s + LC_ALL=C.UTF-8 294s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 295s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 295s 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" 295s 295s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 296s ============================= test session starts ============================== 296s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 296s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 296s rootdir: /usr/lib/python3/dist-packages/pandas 296s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 296s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 296s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 296s collected 793 items 296s 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 296s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 297s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 297s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 297s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 297s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 297s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 297s 297s =============================== warnings summary =============================== 297s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 297s /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-5wets959' 297s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 297s 297s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 297s /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-5xednyz9' 297s session.config.cache.set(STEPWISE_CACHE_DIR, []) 297s 297s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 297s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 297s ============================= slowest 30 durations ============================= 297s 0.01s call tests/copy_view/test_internals.py::test_exponential_backoff 297s 297s (29 durations < 0.005s hidden. Use -vv to show these durations.) 297s ================== 787 passed, 6 skipped, 2 warnings in 2.31s ================== 297s + echo 'rdjoqkol test state = true' 297s + for TEST_SUBSET in $modpath/tests/* 297s rdjoqkol test state = true 297s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 297s + grep -q -e __pycache__ 297s + PANDAS_CI=1 297s + LC_ALL=C.UTF-8 297s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 298s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 298s 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" 298s 298s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 299s ============================= test session starts ============================== 299s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 299s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 299s rootdir: /usr/lib/python3/dist-packages/pandas 299s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 299s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 299s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 299s collected 5628 items 299s 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 299s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 303s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 303s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 303s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 303s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 304s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 304s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 305s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 305s 305s =============================== warnings summary =============================== 305s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 305s /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-0jh9tren' 305s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 305s 305s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 305s /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-mpfbc5_z' 305s session.config.cache.set(STEPWISE_CACHE_DIR, []) 305s 305s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 305s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 305s ============================= slowest 30 durations ============================= 305s 0.08s call tests/dtypes/test_common.py::test_is_sparse[True] 305s 0.07s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 305s 0.02s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 305s 305s (27 durations < 0.005s hidden. Use -vv to show these durations.) 305s ============ 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 7.07s ============ 305s + echo 'rdjoqkol test state = true' 305s + for TEST_SUBSET in $modpath/tests/* 305s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 305s + grep -q -e __pycache__ 305s rdjoqkol test state = true 305s + PANDAS_CI=1 305s + LC_ALL=C.UTF-8 305s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 306s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 306s 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" 306s 306s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 309s ============================= test session starts ============================== 309s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 309s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 309s rootdir: /usr/lib/python3/dist-packages/pandas 309s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 309s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 309s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 309s collected 16808 items / 1 skipped 309s 309s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 312s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 324s ../../../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. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 326s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 326s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 327s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 329s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 345s ../../../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 351s ../../../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.. 353s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 364s ../../../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. 368s ../../../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 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-dofet50j' 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-ed4wagc4' 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.bEGXx0/autopkgtest_tmp/test-data.xml --- 368s ============================= slowest 30 durations ============================= 368s 0.15s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 368s 0.11s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 368s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 368s 0.06s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index2] 368s 0.06s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 368s 0.05s call tests/extension/test_categorical.py::TestCategorical::test_unstack[frame-index2] 368s 0.05s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 368s 0.05s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 368s 0.05s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index3] 368s 0.04s call tests/extension/test_categorical.py::TestCategorical::test_unstack[series-index3] 368s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 368s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 368s 0.04s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 368s 0.04s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 368s 0.04s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 368s 0.04s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 368s 0.04s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index3] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 368s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__pow__] 368s 0.04s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index2] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 368s 0.04s call tests/extension/test_period.py::TestPeriodArray::test_unstack[2D-series-index3] 368s 0.04s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index3] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 368s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_frame_with_scalar[__rpow__] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt8Dtype-series-index2] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 368s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-frame-index2] 368s 0.04s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 368s === 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 62.31s (0:01:02) ==== 370s + echo 'rdjoqkol test state = true' 370s + for TEST_SUBSET in $modpath/tests/* 370s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 370s rdjoqkol test state = true 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.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 371s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 371s 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" 371s 371s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 375s ============================= test session starts ============================== 375s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 375s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 375s rootdir: /usr/lib/python3/dist-packages/pandas 375s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 375s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 375s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 375s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 375s 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 375s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 377s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 378s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 378s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 382s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 382s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 382s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 382s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 382s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 383s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 383s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 383s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 383s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 383s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 384s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 386s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 386s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 387s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 388s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................x.....x.....x.....x.......x..... 388s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 388s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 388s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 390s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 393s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 394s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 396s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 399s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 401s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 402s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 403s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 404s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 404s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 407s ../../../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................................ 407s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 407s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 407s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 407s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 407s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 409s ../../../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. 413s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 413s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 419s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 419s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 420s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 420s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 421s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 421s 421s =============================== warnings summary =============================== 421s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 421s /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-ct986km0' 421s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 421s 421s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 421s /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-tgwhpg1f' 421s session.config.cache.set(STEPWISE_CACHE_DIR, []) 421s 421s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 421s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 421s ============================= slowest 30 durations ============================= 421s 1.74s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 421s 1.66s call tests/frame/indexing/test_where.py::test_where_inplace_casting 421s 0.60s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 421s 0.45s call tests/frame/test_reductions.py::TestDataFrameAnalytics::test_idxmax_empty[repeats-True-1] 421s 0.40s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 421s 0.31s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 421s 0.31s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 421s 0.25s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 421s 0.25s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 421s 0.22s 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] 421s 0.21s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 421s 0.16s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 421s 0.12s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 421s 0.12s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 421s 0.11s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 421s 0.11s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 421s 0.10s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 421s 0.09s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 421s 0.09s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 421s 0.09s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 421s 0.08s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 421s 0.07s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[timedelta-DataFrame] 421s 0.07s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 421s 0.07s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[period-DataFrame] 421s 0.07s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 421s 0.06s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 421s 0.06s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[uint32-DataFrame] 421s 0.06s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 421s 0.06s call tests/frame/methods/test_head_tail.py::test_head_tail_generic[uint64-DataFrame] 421s 0.05s call tests/frame/test_stack_unstack.py::TestDataFrameReshape::test_stack_int_level_names[False] 421s = 10438 passed, 206 skipped, 433 deselected, 64 xfailed, 32 xpassed, 2 warnings in 49.76s = 422s rdjoqkol test state = true 422s + echo 'rdjoqkol test state = true' 422s + for TEST_SUBSET in $modpath/tests/* 422s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 422s + grep -q -e __pycache__ 422s + PANDAS_CI=1 422s + LC_ALL=C.UTF-8 422s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 422s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 422s 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" 422s 422s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 423s ============================= test session starts ============================== 423s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 423s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 423s rootdir: /usr/lib/python3/dist-packages/pandas 423s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 423s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 423s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 423s collected 1249 items 423s 423s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 427s ../../../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. 427s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 427s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 427s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 427s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 427s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 427s bar a b c d e f g h 427s foo 427s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 427s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 427s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 427s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 427s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 427s bar 427s a object 427s b int64 427s c uint8 427s d float64 427s e bool 427s f category 427s g datetime64[ns] 427s h datetime64[ns, US/Eastern] 427s dtype: object 427s actual 427s Size: 236B 427s Dimensions: (foo: 4) 427s Coordinates: 427s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 427s Data variables: 427s a (foo) object 32B 'a' 'b' 'c' 'd' 427s b (foo) int64 32B 1 2 3 4 427s c (foo) uint8 4B 3 4 5 6 427s d (foo) float64 32B 4.0 5.0 6.0 7.0 427s e (foo) bool 4B True False True False 427s f (foo) category 36B Size: 236B 427s Dimensions: (foo: 4) 427s Coordinates: 427s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 427s Data variables: 427s a (foo) object 32B 'a' 'b' 'c' 'd' 427s b (foo) int64 32B 1 2 3 4 427s c (foo) uint8 4B 3 4 5 6 427s d (foo) float64 32B 4.0 5.0 6.0 7.0 427s e (foo) bool 4B True False True False 427s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int64 32B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 208B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int8 4B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 212B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int16 8B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 220B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int32 16B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int64 32B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 208B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) uint8 4B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 212B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) uint16 8B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 220B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) uint32 16B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) uint64 32B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 220B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B True False True False 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 208B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) bool 4B True False True False 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 268B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 'a' 'b' 'c' 'd' 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) int64 32B 0 0 1 1 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 0 1 2 3 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 0.0 1.0 2.0 3.0 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B False True True True 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B Size: 236B 428s Dimensions: (foo: 4) 428s Coordinates: 428s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 428s Data variables: 428s a (foo) object 32B 'a' 'b' 'c' 'd' 428s b (foo) int64 32B 1 2 3 4 428s c (foo) uint8 4B 3 4 5 6 428s d (foo) float64 32B 4.0 5.0 6.0 7.0 428s e (foo) bool 4B True False True False 428s f (foo) category 36B 4] 576s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 576s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 576s 0.01s call tests/interchange/test_impl.py::test_dataframe[1] 576s 0.01s call tests/interchange/test_impl.py::test_dataframe[2] 576s 576s (25 durations < 0.005s hidden. Use -vv to show these durations.) 576s ================== 61 passed, 79 skipped, 2 warnings in 0.40s ================== 576s + echo 'rdjoqkol test state = true' 576s + for TEST_SUBSET in $modpath/tests/* 576s rdjoqkol test state = true 576s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 576s + grep -q -e __pycache__ 576s + PANDAS_CI=1 576s + LC_ALL=C.UTF-8 576s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 577s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 577s 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" 577s 577s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 577s ============================= test session starts ============================== 577s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 577s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 577s rootdir: /usr/lib/python3/dist-packages/pandas 577s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 577s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 577s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 577s collected 257 items 577s 577s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 578s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 579s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 579s 579s =============================== warnings summary =============================== 579s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 579s /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-26eyd1kw' 579s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 579s 579s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 579s /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-plqhqkd5' 579s session.config.cache.set(STEPWISE_CACHE_DIR, []) 579s 579s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 579s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 579s ============================= slowest 30 durations ============================= 579s 0.32s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 579s 0.32s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 579s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 579s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;e:dt;f:td;g:string] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-uint64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-float64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-uint64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-int64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-int64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-uint64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-int64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-float64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-uint64] 579s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-float64] 579s 579s (15 durations < 0.005s hidden. Use -vv to show these durations.) 579s ======================= 257 passed, 2 warnings in 1.50s ======================== 579s rdjoqkol test state = true 579s + echo 'rdjoqkol test state = true' 579s + for TEST_SUBSET in $modpath/tests/* 579s + echo /usr/lib/python3/dist-packages/pandas/tests/io 579s + grep -q -e __pycache__ 579s + PANDAS_CI=1 579s + LC_ALL=C.UTF-8 579s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 579s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 579s 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" 579s 579s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 586s ============================= test session starts ============================== 586s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 586s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 586s rootdir: /usr/lib/python3/dist-packages/pandas 586s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 586s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 586s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 586s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 586s 586s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 586s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py ......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..sssssssssss..s..s.sssssssssssssssssss..s..s.sssssssssssssssssssssssssssssss............ss..ssssssssss......s.sssssssssssssssssss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss.xx.xxs.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......sssssss......sssssss......s.sssss......s.sssss......s.sssss......s.sssss..................sss...sssssssssssssss......s.sssss......s.sssss....................................ssssss......ssssssssssssssssssssssssssssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss......s.sssss............ss..ssssssssss......s.sssss......s.sssss......sssssss...ssss.sssss 600s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 611s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 612s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 612s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 614s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 614s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 614s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 615s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 615s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 616s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 616s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 617s ../../../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....... 617s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 617s ../../../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........................... 618s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 618s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 620s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx........................................................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 621s ../../../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........... 621s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 621s ../../../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 622s ../../../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 622s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 622s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py ...s...s...s...s...s.................................sssssssssss...s...s...s...s...s...s...s...s............ssss.....................sssssss...s...s...s...s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 623s ../../../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 623s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 624s ../../../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 626s ../../../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 626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 626s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 628s ../../../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 628s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 628s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 628s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 629s ../../../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 630s ../../../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 630s ../../../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 630s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 631s ../../../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 637s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 638s ../../../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 638s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 638s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 639s ../../../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 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 639s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 639s ../../../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 641s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 642s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 642s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 642s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 642s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 646s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx................................................................................................................................... 646s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 647s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 647s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 647s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 647s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 648s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 650s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 652s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 652s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 652s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 653s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 654s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 655s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 655s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 656s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 656s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 657s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 657s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 657s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 657s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 665s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 669s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 669s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 675s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 675s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py .ss 675s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 689s ../../../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................ 694s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 695s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 698s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py ........................................................................................s............................................................................s......s......s......s......s......s......s......s......s......s......s......s..s.sss.sss. 698s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 698s 698s =============================== warnings summary =============================== 698s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 698s /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-a95d7jf3' 698s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 698s 698s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 698s /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-zez_vjn0' 698s session.config.cache.set(STEPWISE_CACHE_DIR, []) 698s 698s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 698s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 698s ============================= slowest 30 durations ============================= 698s 1.17s call tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 698s 1.02s call tests/io/pytables/test_store.py::test_no_track_times 698s 0.98s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 698s 0.83s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 698s 0.83s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-stata_responder-read_stata] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-explicit] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-csv_responder-read_csv] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-csv_responder-read_csv] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-c-explicit] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-json_responder-read_json] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-csv_responder-read_csv] 698s 0.50s teardown tests/io/parser/test_network.py::test_url_encoding_csv 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-python-infer] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[xz-c-infer] 698s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[etree] 698s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[lxml] 698s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 698s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-explicit] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 698s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[c_high] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-html_responder-] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-html_responder-] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-infer] 698s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-html_responder-] 698s 0.50s teardown tests/io/xml/test_xml.py::test_url 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-python-explicit] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-c-infer] 698s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-c-explicit] 698s = 12149 passed, 3016 skipped, 201 deselected, 155 xfailed, 2 warnings in 118.95s (0:01:58) = 700s + echo 'rdjoqkol test state = true' 700s + for TEST_SUBSET in $modpath/tests/* 700s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 700s rdjoqkol test state = true 700s + grep -q -e __pycache__ 700s + PANDAS_CI=1 700s + LC_ALL=C.UTF-8 700s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 701s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 701s 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" 701s 701s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 701s ============================= test session starts ============================== 701s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 701s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 701s rootdir: /usr/lib/python3/dist-packages/pandas 701s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 701s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 701s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 701s collected 2279 items 701s 703s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 703s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 703s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 703s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 703s 703s =============================== warnings summary =============================== 703s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 703s /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-ockjzphy' 703s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 703s 703s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 703s /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-4w631zn6' 703s session.config.cache.set(STEPWISE_CACHE_DIR, []) 703s 703s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 703s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 703s ============================= slowest 30 durations ============================= 703s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 703s 703s (29 durations < 0.005s hidden. Use -vv to show these durations.) 703s ================= 2273 passed, 6 skipped, 2 warnings in 2.33s ================== 703s + echo 'rdjoqkol test state = true' 703s + for TEST_SUBSET in $modpath/tests/* 703s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 703s + grep -q -e __pycache__ 703s + PANDAS_CI=1 703s + LC_ALL=C.UTF-8 703s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 703s rdjoqkol test state = true 704s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 704s 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" 704s 704s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 705s ============================= test session starts ============================== 705s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 705s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 705s rootdir: /usr/lib/python3/dist-packages/pandas 705s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 705s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 705s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 705s collected 1423 items / 212 deselected / 1211 selected 705s 720s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 725s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 726s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 732s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 734s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 735s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 746s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 751s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 757s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 760s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 760s 760s =============================== warnings summary =============================== 760s tests/plotting/frame/test_frame.py: 11 warnings 760s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 760s x_scale = 1.0 / inw 760s 760s tests/plotting/frame/test_frame.py: 11 warnings 760s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 760s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 760s 760s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 760s /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-d0nzj16j' 760s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 760s 760s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 760s /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-_bybe7cg' 760s session.config.cache.set(STEPWISE_CACHE_DIR, []) 760s 760s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 760s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 760s ============================= slowest 30 durations ============================= 760s 0.59s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 760s 0.56s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 760s 0.55s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 760s 0.45s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 760s 0.43s call tests/plotting/test_converter.py::test_registry_mpl_resets 760s 0.42s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 760s 0.38s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 760s 0.37s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 760s 0.37s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 760s 0.36s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 760s 0.35s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 760s 0.34s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 760s 0.31s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 760s 0.31s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 760s 0.31s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 760s 0.27s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 760s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 760s 0.27s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 760s 0.27s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 760s 0.27s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 760s 0.25s call tests/plotting/test_datetimelike.py::TestTSPlot::test_frame_inferred 760s 0.24s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_datetime_frame[D] 760s 0.24s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 760s 0.24s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_period_mlt_series[4D] 760s 0.24s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 760s 0.23s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 760s 0.22s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 760s 0.20s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 760s 0.18s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 760s 0.18s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 760s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 56.41s = 761s rdjoqkol test state = true 761s + echo 'rdjoqkol test state = true' 761s + for TEST_SUBSET in $modpath/tests/* 761s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 761s + grep -q -e __pycache__ 761s + PANDAS_CI=1 761s + LC_ALL=C.UTF-8 761s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 762s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 762s 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" 762s 762s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 762s ============================= test session starts ============================== 762s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 762s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 762s rootdir: /usr/lib/python3/dist-packages/pandas 762s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 762s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 762s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 762s collected 550 items 762s 763s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 763s 763s =============================== warnings summary =============================== 763s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 763s /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-8nm2npe_' 763s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 763s 763s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 763s /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-mxm15uhf' 763s session.config.cache.set(STEPWISE_CACHE_DIR, []) 763s 763s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 763s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 763s ============================= slowest 30 durations ============================= 763s 0.32s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 763s 0.04s call tests/reductions/test_reductions.py::TestReductions::test_same_tz_min_max_axis_1[max-a] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 763s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 763s 763s (20 durations < 0.005s hidden. Use -vv to show these durations.) 763s ================== 549 passed, 1 skipped, 2 warnings in 1.59s ================== 763s + echo 'rdjoqkol test state = true' 763s rdjoqkol test state = true 763s + for TEST_SUBSET in $modpath/tests/* 763s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 763s + grep -q -e __pycache__ 763s + PANDAS_CI=1 763s + LC_ALL=C.UTF-8 763s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 764s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 764s 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" 764s 764s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 765s ============================= test session starts ============================== 765s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 765s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 765s rootdir: /usr/lib/python3/dist-packages/pandas 765s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 765s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 765s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 765s collected 4179 items 765s 768s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 781s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 785s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 785s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 786s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 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-1am9m7b7' 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-_zu8fa90' 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.bEGXx0/autopkgtest_tmp/test-data.xml --- 786s ============================= slowest 30 durations ============================= 786s 0.14s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 786s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-1] 786s 0.09s call tests/resample/test_period_index.py::TestPeriodIndex::test_annual_upsample_cases[D-D-start-bfill-OCT] 786s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-2] 786s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-2] 786s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-3600-s-1-h-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-1] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-2] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-86400-s-1-D-3] 786s 0.07s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-1] 786s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 21.73s =========== 786s rdjoqkol test state = true 786s + echo 'rdjoqkol test state = true' 786s + for TEST_SUBSET in $modpath/tests/* 786s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 786s + grep -q -e __pycache__ 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.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 787s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 787s 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" 787s 787s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 788s ============================= test session starts ============================== 788s platform linux -- Python 3.13.3, 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.bEGXx0/build.t5V/src/pyproject.toml 788s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 788s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 788s collected 2610 items / 1 deselected / 2609 selected 788s 789s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 789s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 789s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 789s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 789s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 790s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 794s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 794s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 795s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 795s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 795s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 796s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 796s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 796s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 797s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 799s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 799s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 800s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 800s 800s =============================== warnings summary =============================== 800s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 800s /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-5hdnw4se' 800s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 800s 800s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 800s /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-5l_vktus' 800s session.config.cache.set(STEPWISE_CACHE_DIR, []) 800s 800s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 800s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 800s ============================= slowest 30 durations ============================= 800s 0.06s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 800s 0.06s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 800s 0.06s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 800s 0.05s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 800s 0.05s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 800s 0.05s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 800s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 800s 0.04s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 800s 0.04s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 800s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 800s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 800s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 800s 0.03s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 800s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 800s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 800s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 800s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize_multiple_columns 800s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 800s 0.02s call tests/reshape/test_qcut.py::test_qcut_binning_issues 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 800s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 800s 0.02s call tests/reshape/merge/test_join.py::TestJoin::test_join_many_non_unique_index 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_with_ordered_categorical_column 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 800s 0.02s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_errors 800s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 800s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 800s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 13.06s ==== 800s + echo 'rdjoqkol test state = true' 800s + for TEST_SUBSET in $modpath/tests/* 800s rdjoqkol test state = true 800s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 800s + grep -q -e __pycache__ 800s + PANDAS_CI=1 800s + LC_ALL=C.UTF-8 800s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 801s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 801s 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" 801s 801s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 803s ============================= test session starts ============================== 803s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 803s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 803s rootdir: /usr/lib/python3/dist-packages/pandas 803s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 803s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 803s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 803s collected 4353 items 803s 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 803s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 805s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 807s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 807s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 808s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 809s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 809s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 809s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 809s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 809s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 812s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 812s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 812s 812s =============================== warnings summary =============================== 812s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 812s /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-wwpc7_2c' 812s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 812s 812s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 812s /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-7i80m0xs' 812s session.config.cache.set(STEPWISE_CACHE_DIR, []) 812s 812s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 812s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 812s ============================= slowest 30 durations ============================= 812s 1.90s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 812s 0.12s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 812s 0.12s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 812s 0.11s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 812s 0.11s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 812s 0.11s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 812s 0.10s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 812s 0.08s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 812s 0.02s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 812s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_add_offset 812s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 812s 0.01s call tests/scalar/period/test_period.py::TestPeriodConstruction::test_period_cons_weekly[14-SUN] 812s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_sub_offset 812s 0.01s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_names[ltg_LV.UTF-8-data0] 812s 812s (16 durations < 0.005s hidden. Use -vv to show these durations.) 812s =========== 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 11.03s ============ 812s rdjoqkol test state = true 812s + echo 'rdjoqkol test state = true' 812s + for TEST_SUBSET in $modpath/tests/* 812s + echo /usr/lib/python3/dist-packages/pandas/tests/series 812s + grep -q -e __pycache__ 812s + PANDAS_CI=1 812s + LC_ALL=C.UTF-8 812s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 813s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 813s 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" 813s 813s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 817s ============================= test session starts ============================== 817s platform linux -- Python 3.13.3, 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.bEGXx0/build.t5V/src/pyproject.toml 817s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 817s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 817s collected 13032 items / 2 skipped 817s 817s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 822s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 823s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 824s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 824s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 824s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 828s ../../../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................................................................................................................................................................................................... 828s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 828s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 828s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 828s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 829s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 831s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 832s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 833s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 834s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 835s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 836s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 843s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 845s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 845s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 845s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 845s 845s =============================== warnings summary =============================== 845s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 845s /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-a3785hh_' 845s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 845s 845s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 845s /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-_2g52_5n' 845s session.config.cache.set(STEPWISE_CACHE_DIR, []) 845s 845s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 845s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 845s ============================= slowest 30 durations ============================= 845s 0.29s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 845s 0.27s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 845s 0.26s call tests/series/methods/test_rank.py::test_pct_max_many_rows 845s 0.22s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-truediv-True-Series] 845s 0.16s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases14-params5] 845s 0.11s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 845s 0.06s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 845s 0.05s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 845s 0.02s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[zh_CN.gb2312] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[sgs_LT.UTF-8] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[bn_IN.UTF-8] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[zh_CN.gb18030] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[zh_CN.gbk] 845s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx0] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[zh_CN.UTF-8] 845s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[uz_UZ.UTF-8_1] 845s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[bn_BD.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[tr_TR.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[tt_RU.UTF-8@iqtelif] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[uz_UZ.UTF-8_2] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[bo_CN.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[tr_CY.ISO8859-9] 845s 0.01s call tests/series/methods/test_to_csv.py::TestSeriesToCSV::test_from_csv 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[bo_IN.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[uk_UA.UTF-8] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[uk_UA.KOI8-U] 845s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[tr_TR.ISO8859-9] 845s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 32.44s ========== 847s + echo 'rdjoqkol test state = true' 847s + for TEST_SUBSET in $modpath/tests/* 847s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 847s rdjoqkol test state = true 847s + grep -q -e __pycache__ 847s + PANDAS_CI=1 847s + LC_ALL=C.UTF-8 847s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 848s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 848s 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" 848s 848s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 848s ============================= test session starts ============================== 848s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 848s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 848s rootdir: /usr/lib/python3/dist-packages/pandas 848s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 848s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 848s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 848s collected 3604 items 848s 852s ../../../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 852s ../../../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 852s ../../../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...................................... 853s ../../../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 853s ../../../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 853s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 854s ../../../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 854s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 854s ../../../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....... 854s 854s =============================== warnings summary =============================== 854s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 854s /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-yeqiuxlo' 854s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 854s 854s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 854s /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-8x89bchs' 854s session.config.cache.set(STEPWISE_CACHE_DIR, []) 854s 854s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 854s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 854s ============================= slowest 30 durations ============================= 854s 0.10s setup tests/strings/test_strings.py::test_count_mixed_object 854s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 854s 0.01s teardown tests/strings/test_strings.py::test_series_str_decode 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 854s 0.01s call tests/strings/test_extract.py::test_extractall[string[python]] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data1-names1] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 854s 0.01s call tests/strings/test_extract.py::test_extractall[object] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 854s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 854s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 854s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[object] 854s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 854s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data4-names4] 854s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[object] 854s 0.01s call tests/strings/test_cat.py::test_str_cat_mixed_inputs[index] 854s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[string[python]] 854s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[object] 854s 0.01s call tests/strings/test_extract.py::test_extractall_stringindex[object] 854s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 6.45s =========== 855s + echo 'rdjoqkol test state = true' 855s + for TEST_SUBSET in $modpath/tests/* 855s rdjoqkol test state = true 855s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 855s + grep -q -e __pycache__ 855s + PANDAS_CI=1 855s + LC_ALL=C.UTF-8 855s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 855s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 855s 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" 855s 855s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 855s ============================= test session starts ============================== 855s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 855s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 855s rootdir: /usr/lib/python3/dist-packages/pandas 855s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 855s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 855s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 855s collected 8 items 855s 855s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 855s 855s =============================== warnings summary =============================== 855s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 855s /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-i9d4uza0' 855s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 855s 855s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 855s /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-5k4_wl6b' 855s session.config.cache.set(STEPWISE_CACHE_DIR, []) 855s 855s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 855s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 855s ============================= slowest 30 durations ============================= 855s 855s (24 durations < 0.005s hidden. Use -vv to show these durations.) 855s ======================== 8 passed, 2 warnings in 0.12s ========================= 855s rdjoqkol test state = true 855s + echo 'rdjoqkol test state = true' 855s + for TEST_SUBSET in $modpath/tests/* 855s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 855s + grep -q -e __pycache__ 855s + PANDAS_CI=1 855s + LC_ALL=C.UTF-8 855s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 856s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 856s 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" 856s 856s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 856s ============================= test session starts ============================== 856s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 856s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 856s rootdir: /usr/lib/python3/dist-packages/pandas 856s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 856s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 856s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 856s collected 471 items 856s 859s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 859s 859s =============================== warnings summary =============================== 859s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 859s /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-s_uhwlaf' 859s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 859s 859s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 859s /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-n6y175xx' 859s session.config.cache.set(STEPWISE_CACHE_DIR, []) 859s 859s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 859s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 859s ============================= slowest 30 durations ============================= 859s 1.89s call tests/test_algos.py::TestRank::test_pct_max_many_rows 859s 0.32s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 859s 0.02s call tests/test_algos.py::TestIsin::test_large 859s 0.01s call tests/test_algos.py::TestDuplicated::test_datetime_likes 859s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 859s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 859s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large 859s 859s (23 durations < 0.005s hidden. Use -vv to show these durations.) 859s ======================= 471 passed, 2 warnings in 3.14s ======================== 859s rdjoqkol test state = true 859s + echo 'rdjoqkol test state = true' 859s + for TEST_SUBSET in $modpath/tests/* 859s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 859s + grep -q -e __pycache__ 859s + PANDAS_CI=1 859s + LC_ALL=C.UTF-8 859s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 860s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 860s 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" 860s 860s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 860s ============================= test session starts ============================== 860s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 860s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 860s rootdir: /usr/lib/python3/dist-packages/pandas 860s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 860s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 860s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 860s collected 128 items 860s 861s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 861s 861s =============================== warnings summary =============================== 861s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 861s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-1uypxsm9' 861s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 861s 861s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 861s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-eof1c14j' 861s session.config.cache.set(STEPWISE_CACHE_DIR, []) 861s 861s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 861s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 861s ============================= slowest 30 durations ============================= 861s 0.36s call tests/test_common.py::test_bz2_missing_import 861s 0.31s call tests/test_common.py::test_str_size 861s 861s (28 durations < 0.005s hidden. Use -vv to show these durations.) 861s ================== 126 passed, 2 xfailed, 2 warnings in 0.97s ================== 861s rdjoqkol test state = true 861s + echo 'rdjoqkol test state = true' 861s + for TEST_SUBSET in $modpath/tests/* 861s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 861s + grep -q -e __pycache__ 861s + PANDAS_CI=1 861s + LC_ALL=C.UTF-8 861s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 862s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 862s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 862s 862s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 862s ============================= test session starts ============================== 862s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 862s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 862s rootdir: /usr/lib/python3/dist-packages/pandas 862s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 862s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 862s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 862s collected 26 items 862s 866s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 866s 866s =============================== warnings summary =============================== 866s tests/test_downstream.py::test_dask 866s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 866s Dask dataframe query planning is disabled because dask-expr is not installed. 866s 866s You can install it with `pip install dask[dataframe]` or `conda install dask`. 866s This will raise in a future version. 866s 866s warnings.warn(msg, FutureWarning) 866s 866s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 866s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-fyd3jqgf' 866s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 866s 866s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 866s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-_vytqjgt' 866s session.config.cache.set(STEPWISE_CACHE_DIR, []) 866s 866s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 866s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 866s ============================= slowest 30 durations ============================= 866s 1.57s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 866s 1.54s call tests/test_downstream.py::test_oo_optimizable 866s 0.10s call tests/test_downstream.py::test_dask 866s 0.01s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 866s 0.01s call tests/test_downstream.py::test_yaml_dump 866s 866s (25 durations < 0.005s hidden. Use -vv to show these durations.) 866s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 3.81s ============= 866s rdjoqkol test state = true 866s + echo 'rdjoqkol test state = true' 866s + for TEST_SUBSET in $modpath/tests/* 866s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 866s + grep -q -e __pycache__ 866s + PANDAS_CI=1 866s + LC_ALL=C.UTF-8 866s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 866s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 866s 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" 866s 866s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 867s ============================= test session starts ============================== 867s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 867s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 867s rootdir: /usr/lib/python3/dist-packages/pandas 867s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 867s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 867s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 867s collected 36 items 867s 867s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 867s 867s =============================== warnings summary =============================== 867s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 867s /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-zg3lkqop' 867s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 867s 867s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 867s /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-8khxvuc3' 867s session.config.cache.set(STEPWISE_CACHE_DIR, []) 867s 867s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 867s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 867s ============================= slowest 30 durations ============================= 867s 867s (30 durations < 0.005s hidden. Use -vv to show these durations.) 867s ======================== 36 passed, 2 warnings in 0.12s ======================== 867s rdjoqkol test state = true 867s + echo 'rdjoqkol test state = true' 867s + for TEST_SUBSET in $modpath/tests/* 867s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 867s + grep -q -e __pycache__ 867s + PANDAS_CI=1 867s + LC_ALL=C.UTF-8 867s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 867s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 867s 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" 867s 867s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 868s ============================= test session starts ============================== 868s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 868s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 868s rootdir: /usr/lib/python3/dist-packages/pandas 868s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 868s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 868s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 868s collected 243 items 868s 869s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 869s 869s =============================== warnings summary =============================== 869s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 869s /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-_n66iptr' 869s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 869s 869s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 869s /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-1hczfhgn' 869s session.config.cache.set(STEPWISE_CACHE_DIR, []) 869s 869s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 869s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 869s ============================= slowest 30 durations ============================= 869s 0.01s call tests/test_expressions.py::TestExpressions::test_invalid 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_frame] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_integer_integers] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-True-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-False-_mixed] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_frame] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_frame] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_frame] 869s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-True-_mixed] 869s ======================= 243 passed, 2 warnings in 1.16s ======================== 869s rdjoqkol test state = true 869s + echo 'rdjoqkol test state = true' 869s + for TEST_SUBSET in $modpath/tests/* 869s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 869s + grep -q -e __pycache__ 869s + PANDAS_CI=1 869s + LC_ALL=C.UTF-8 869s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 869s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 869s 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" 869s 869s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 870s ============================= test session starts ============================== 870s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 870s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 870s rootdir: /usr/lib/python3/dist-packages/pandas 870s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 870s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 870s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 870s collected 5 items 870s 870s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 870s 870s =============================== warnings summary =============================== 870s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 870s /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-rvfccxzo' 870s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 870s 870s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 870s /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-8bmhbx8o' 870s session.config.cache.set(STEPWISE_CACHE_DIR, []) 870s 870s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 870s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 870s ============================= slowest 30 durations ============================= 870s 870s (15 durations < 0.005s hidden. Use -vv to show these durations.) 870s ======================== 5 passed, 2 warnings in 0.11s ========================= 870s rdjoqkol test state = true 870s + echo 'rdjoqkol test state = true' 870s + for TEST_SUBSET in $modpath/tests/* 870s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 870s + grep -q -e __pycache__ 870s + PANDAS_CI=1 870s + LC_ALL=C.UTF-8 870s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 870s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 870s 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" 870s 870s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 871s ============================= test session starts ============================== 871s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 871s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 871s rootdir: /usr/lib/python3/dist-packages/pandas 871s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 871s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 871s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 871s collected 19 items 871s 871s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 871s 871s =============================== warnings summary =============================== 871s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 871s /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-5naf2awc' 871s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 871s 871s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 871s /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-g9npimvp' 871s session.config.cache.set(STEPWISE_CACHE_DIR, []) 871s 871s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 871s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 871s ============================= slowest 30 durations ============================= 871s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 871s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_alignment 871s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level_partial_selection 871s 871s (27 durations < 0.005s hidden. Use -vv to show these durations.) 871s ======================== 19 passed, 2 warnings in 0.20s ======================== 871s + echo 'rdjoqkol test state = true' 871s + for TEST_SUBSET in $modpath/tests/* 871s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 871s + grep -q -e __pycache__ 871s rdjoqkol test state = true 871s + PANDAS_CI=1 871s + LC_ALL=C.UTF-8 871s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 871s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 871s 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" 871s 871s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 872s ============================= test session starts ============================== 872s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 872s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 872s rootdir: /usr/lib/python3/dist-packages/pandas 872s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 872s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 872s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 872s collected 245 items 872s 872s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 872s 872s =============================== warnings summary =============================== 872s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 872s /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-2jetvum4' 872s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 872s 872s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 872s /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-6u_szi_c' 872s session.config.cache.set(STEPWISE_CACHE_DIR, []) 872s 872s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 872s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 872s ============================= slowest 30 durations ============================= 872s 0.31s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 872s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-2] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-1] 872s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-0] 872s 872s (14 durations < 0.005s hidden. Use -vv to show these durations.) 872s ======================= 245 passed, 2 warnings in 1.05s ======================== 873s rdjoqkol test state = true 873s + echo 'rdjoqkol test state = true' 873s + for TEST_SUBSET in $modpath/tests/* 873s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 873s + grep -q -e __pycache__ 873s + PANDAS_CI=1 873s + LC_ALL=C.UTF-8 873s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 873s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 873s 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" 873s 873s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 873s ============================= test session starts ============================== 873s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 873s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 873s rootdir: /usr/lib/python3/dist-packages/pandas 873s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 873s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 873s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 873s collected 5 items 873s 873s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 873s 873s =============================== warnings summary =============================== 873s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 873s /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-036u9eau' 873s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 873s 873s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 873s /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-awgeevyg' 873s session.config.cache.set(STEPWISE_CACHE_DIR, []) 873s 873s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 873s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 873s ============================= slowest 30 durations ============================= 873s 873s (15 durations < 0.005s hidden. Use -vv to show these durations.) 873s ======================== 5 passed, 2 warnings in 0.10s ========================= 874s + echo 'rdjoqkol test state = true' 874s + for TEST_SUBSET in $modpath/tests/* 874s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 874s + grep -q -e __pycache__ 874s rdjoqkol test state = true 874s + PANDAS_CI=1 874s + LC_ALL=C.UTF-8 874s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 874s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 874s 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" 874s 874s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 874s ============================= test session starts ============================== 874s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 874s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 874s rootdir: /usr/lib/python3/dist-packages/pandas 874s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 874s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 874s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 874s collected 7 items 874s 874s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 874s 874s =============================== warnings summary =============================== 874s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 874s /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-g6yu9163' 874s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 874s 874s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 874s /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-8hpk11nu' 874s session.config.cache.set(STEPWISE_CACHE_DIR, []) 874s 874s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 874s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 874s ============================= slowest 30 durations ============================= 874s 874s (21 durations < 0.005s hidden. Use -vv to show these durations.) 874s ======================== 7 passed, 2 warnings in 0.11s ========================= 875s + echo 'rdjoqkol test state = true' 875s + for TEST_SUBSET in $modpath/tests/* 875s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 875s rdjoqkol test state = true 875s + grep -q -e __pycache__ 875s + PANDAS_CI=1 875s + LC_ALL=C.UTF-8 875s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 875s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 875s 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" 875s 875s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 875s ============================= test session starts ============================== 875s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 875s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 875s rootdir: /usr/lib/python3/dist-packages/pandas 875s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 875s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 875s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 875s collected 54 items / 15 deselected / 39 selected 875s 876s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 876s 876s =============================== warnings summary =============================== 876s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 876s /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-gaxin9r6' 876s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 876s 876s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 876s /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-honqjt9w' 876s session.config.cache.set(STEPWISE_CACHE_DIR, []) 876s 876s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 876s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 876s ============================= slowest 30 durations ============================= 876s 0.48s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 876s 0.21s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 876s 0.21s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 876s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 876s 876s (26 durations < 0.005s hidden. Use -vv to show these durations.) 876s ================ 39 passed, 15 deselected, 2 warnings in 1.06s ================= 876s rdjoqkol test state = true 876s + echo 'rdjoqkol test state = true' 876s + for TEST_SUBSET in $modpath/tests/* 876s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 876s + grep -q -e __pycache__ 876s + PANDAS_CI=1 876s + LC_ALL=C.UTF-8 876s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 877s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 877s 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" 877s 877s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 877s ============================= test session starts ============================== 877s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 877s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 877s rootdir: /usr/lib/python3/dist-packages/pandas 877s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 877s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 877s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 877s collected 81 items 877s 877s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 877s 877s =============================== warnings summary =============================== 877s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 877s /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-ps39plwl' 877s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 877s 877s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 877s /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-ybkasngu' 877s session.config.cache.set(STEPWISE_CACHE_DIR, []) 877s 877s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 877s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 877s ============================= slowest 30 durations ============================= 877s 877s (30 durations < 0.005s hidden. Use -vv to show these durations.) 877s ======================== 81 passed, 2 warnings in 0.20s ======================== 877s rdjoqkol test state = true 877s + echo 'rdjoqkol test state = true' 877s + for TEST_SUBSET in $modpath/tests/* 877s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 877s + grep -q -e __pycache__ 877s + PANDAS_CI=1 877s + LC_ALL=C.UTF-8 877s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 878s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 878s 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" 878s 878s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 879s ============================= test session starts ============================== 879s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 879s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 879s rootdir: /usr/lib/python3/dist-packages/pandas 879s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 879s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 879s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 879s collected 1510 items 879s 881s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 882s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 882s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 882s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 882s 882s =============================== warnings summary =============================== 882s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 882s /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-o5973m9p' 882s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 882s 882s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 882s /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-xb0g3eth' 882s session.config.cache.set(STEPWISE_CACHE_DIR, []) 882s 882s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 882s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 882s ============================= slowest 30 durations ============================= 882s 0.06s 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] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 882s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 882s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 882s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 882s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 882s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 882s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeDataFrame::test_dataframe[True] 882s 882s (1 durations < 0.005s hidden. Use -vv to show these durations.) 882s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 3.57s ============ 882s rdjoqkol test state = true 882s + echo 'rdjoqkol test state = true' 882s + for TEST_SUBSET in $modpath/tests/* 882s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 882s + grep -q -e __pycache__ 882s + PANDAS_CI=1 882s + LC_ALL=C.UTF-8 882s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 882s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 882s 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" 882s 882s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 883s ============================= test session starts ============================== 883s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 883s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 883s rootdir: /usr/lib/python3/dist-packages/pandas 883s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 883s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 883s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 883s collected 5480 items 883s 884s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 884s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 885s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 886s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 886s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 886s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 886s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 886s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 887s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 892s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 892s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 893s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 894s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 894s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 894s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 894s 894s =============================== warnings summary =============================== 894s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 894s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 894s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 894s 894s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 894s /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-ce2vddpp' 894s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 894s 894s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 894s /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-a8ez9568' 894s session.config.cache.set(STEPWISE_CACHE_DIR, []) 894s 894s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 894s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 894s ============================= slowest 30 durations ============================= 894s 0.36s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 894s 0.30s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 894s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 894s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 894s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 894s 0.17s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 894s 0.16s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 894s 0.16s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 894s 0.16s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 894s 0.09s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 894s 0.09s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[tzlocal()-YearEnd] 894s 0.09s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 894s 0.07s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 894s 0.07s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 894s 0.07s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 894s 0.07s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 894s 0.07s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 894s 0.02s call tests/tseries/offsets/test_offsets.py::TestCommon::test_rollback[CustomBusinessMonthBegin0] 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 894s 0.02s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 894s 0.02s teardown tests/tseries/offsets/test_year.py::test_add_out_of_pydatetime_range 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[MonthBegin--2] 894s 0.02s call tests/tseries/holiday/test_calendar.py::test_calendar_2031 894s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 894s 0.02s call tests/tseries/offsets/test_fiscal.py::TestFY5253LastOfMonthQuarter::test_offset 894s 0.02s call tests/tseries/holiday/test_calendar.py::test_calendar_observance_dates 894s ================= 5478 passed, 2 xfailed, 3 warnings in 11.97s ================= 895s + echo 'rdjoqkol test state = true' 895s + for TEST_SUBSET in $modpath/tests/* 895s rdjoqkol test state = true 895s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 895s + grep -q -e __pycache__ 895s + PANDAS_CI=1 895s + LC_ALL=C.UTF-8 895s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 896s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 896s 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" 896s 896s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 896s ============================= test session starts ============================== 896s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 896s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 896s rootdir: /usr/lib/python3/dist-packages/pandas 896s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 896s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 896s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 896s collected 1140 items 896s 896s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 896s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 896s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 898s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 903s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 903s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 904s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 904s 904s =============================== warnings summary =============================== 904s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 904s /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-j0dimyg6' 904s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 904s 904s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 904s /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-fv_krads' 904s session.config.cache.set(STEPWISE_CACHE_DIR, []) 904s 904s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 904s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 904s ============================= slowest 30 durations ============================= 904s 0.37s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 904s 0.20s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 904s 0.17s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 904s 0.17s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 904s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 904s 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')] 904s 0.14s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-.] 904s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 904s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 904s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 904s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 904s 0.13s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 904s 0.12s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 904s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False--] 904s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-/] 904s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True- ] 904s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 904s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-.] 904s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True--] 904s 0.10s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 904s 0.10s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 904s 0.10s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False- ] 904s 0.09s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-/] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False- ] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-.] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True--] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False- ] 904s 0.08s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 904s ================= 1138 passed, 2 xfailed, 2 warnings in 8.66s ================== 905s rdjoqkol test state = true 905s + echo 'rdjoqkol test state = true' 905s + for TEST_SUBSET in $modpath/tests/* 905s + echo /usr/lib/python3/dist-packages/pandas/tests/util 905s + grep -q -e __pycache__ 905s + PANDAS_CI=1 905s + LC_ALL=C.UTF-8 905s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 905s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 905s 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" 905s 905s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 906s ============================= test session starts ============================== 906s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 906s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 906s rootdir: /usr/lib/python3/dist-packages/pandas 906s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 906s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 906s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 906s collected 916 items 906s 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 906s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 907s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 907s 907s =============================== warnings summary =============================== 907s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 907s /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-8_zatwrj' 907s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 907s 907s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 907s /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-9n3x3z1l' 907s session.config.cache.set(STEPWISE_CACHE_DIR, []) 907s 907s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 907s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 907s ============================= slowest 30 durations ============================= 907s 0.51s call tests/util/test_show_versions.py::test_show_versions 907s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 907s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 907s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 907s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 907s 0.01s call tests/util/test_show_versions.py::test_json_output_match 907s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 907s 907s (23 durations < 0.005s hidden. Use -vv to show these durations.) 907s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 2.03s ============= 907s rdjoqkol test state = true 907s + echo 'rdjoqkol test state = true' 907s + for TEST_SUBSET in $modpath/tests/* 907s + echo /usr/lib/python3/dist-packages/pandas/tests/window 907s + grep -q -e __pycache__ 907s + PANDAS_CI=1 907s + LC_ALL=C.UTF-8 907s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.bEGXx0/build.t5V/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 908s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 908s 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" 908s 908s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 909s ============================= test session starts ============================== 909s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 909s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 909s rootdir: /usr/lib/python3/dist-packages/pandas 909s configfile: ../../../../../tmp/autopkgtest.bEGXx0/build.t5V/src/pyproject.toml 909s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 909s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 909s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 909s 912s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 912s ../../../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................................................................................................................................................................................................................................................................................ 914s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 915s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 916s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 917s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 917s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 921s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 922s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 923s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 923s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 924s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 926s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 928s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 930s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 930s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 930s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 931s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 931s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 931s 931s =============================== warnings summary =============================== 931s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 931s /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-sl6x1x73' 931s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 931s 931s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 931s /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-6ql79kco' 931s session.config.cache.set(STEPWISE_CACHE_DIR, []) 931s 931s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 931s -- generated xml file: /tmp/autopkgtest.bEGXx0/autopkgtest_tmp/test-data.xml --- 931s ============================= slowest 30 durations ============================= 931s 0.34s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 931s 0.29s teardown tests/window/test_numba.py::TestEngine::test_cache_apply[False-True-True-5-True] 931s 0.18s call tests/window/test_apply.py::test_time_rule_frame[False] 931s 0.12s call tests/window/test_apply.py::test_frame[False] 931s 0.05s call tests/window/test_expanding.py::test_expanding_corr_pairwise 931s 0.05s call tests/window/test_expanding.py::test_expanding_cov_pairwise 931s 0.05s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 931s 0.03s call tests/window/test_apply.py::test_center_reindex_frame[False] 931s 0.03s call tests/window/test_apply.py::test_nans[False] 931s 0.03s call tests/window/test_apply.py::test_min_periods[False-None-0] 931s 0.03s call tests/window/test_apply.py::test_min_periods[False-1-0] 931s 0.03s call tests/window/test_apply.py::test_center_reindex_series[False] 931s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 931s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 931s 0.02s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 931s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 931s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 931s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 931s 0.02s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 931s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 931s 0.02s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 931s 0.02s call tests/window/test_apply.py::test_time_rule_series[False] 931s 0.02s call tests/window/test_apply.py::test_min_periods[False-2-0] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames8-1] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames7-3] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames6-3] 931s 0.01s call tests/window/test_api.py::test_agg[None] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames7-2] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames8-2] 931s 0.01s call tests/window/test_pairwise.py::TestPairwise::test_pairwise_with_other[pairwise_frames3-2] 931s == 9014 passed, 650 skipped, 536 deselected, 43 xfailed, 2 warnings in 23.12s == 932s rdjoqkol test state = true 932s + echo 'rdjoqkol test state = true' 932s + true 932s autopkgtest [17:39:12]: test unittests3: -----------------------] 933s autopkgtest [17:39:13]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 933s unittests3 PASS 934s autopkgtest [17:39:14]: test ignoredtests: preparing testbed 934s Reading package lists... 934s Building dependency tree... 934s Reading state information... 935s Starting pkgProblemResolver with broken count: 0 935s Starting 2 pkgProblemResolver with broken count: 0 935s Done 935s The following NEW packages will be installed: 935s libpq5 python3-psycopg2 python3-pymysql 935s 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 935s Need to get 336 kB of archives. 935s After this operation, 1150 kB of additional disk space will be used. 935s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 libpq5 amd64 17.4-1 [155 kB] 936s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 python3-psycopg2 amd64 2.9.10-1build1 [142 kB] 936s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 936s Fetched 336 kB in 1s (589 kB/s) 936s Selecting previously unselected package libpq5:amd64. 936s (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 ... 104438 files and directories currently installed.) 936s Preparing to unpack .../libpq5_17.4-1_amd64.deb ... 936s Unpacking libpq5:amd64 (17.4-1) ... 936s Selecting previously unselected package python3-psycopg2. 936s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_amd64.deb ... 936s Unpacking python3-psycopg2 (2.9.10-1build1) ... 936s Selecting previously unselected package python3-pymysql. 936s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 936s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 936s Setting up libpq5:amd64 (17.4-1) ... 936s Setting up python3-psycopg2 (2.9.10-1build1) ... 936s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 937s Processing triggers for libc-bin (2.41-6ubuntu1) ... 937s autopkgtest [17:39:17]: test ignoredtests: [----------------------- 938s === python3.13 === 938s 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 939s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 939s 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" 939s 939s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 940s ============================= test session starts ============================== 940s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 940s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 940s rootdir: /usr/lib/python3/dist-packages/pandas/tests 940s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 940s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 940s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 940s 942s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 943s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 945s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 946s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 946s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 972s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 981s ../../../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................................................................................................................................................................................................................................................................................ 999s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1019s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1021s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1027s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1030s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1086s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1093s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1101s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1116s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1145s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1162s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1168s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1170s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1268s 1268s =============================== warnings summary =============================== 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1268s /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 1268s pytestmark = pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1268s /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 1268s @pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1268s /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 1268s pytestmark = pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1268s /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 1268s pytestmark = pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1268s /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 1268s @pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1268s /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 1268s pytestmark = pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1268s /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 1268s @pytest.mark.slow 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1268s /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 1268s pytestmark = pytest.mark.single_cpu 1268s 1268s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1268s /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 1268s @pytest.mark.slow 1268s 1268s frame/test_ufunc.py: 32 warnings 1268s groupby/test_timegrouper.py: 31 warnings 1268s groupby/transform/test_numba.py: 53 warnings 1268s groupby/aggregate/test_numba.py: 35 warnings 1268s util/test_numba.py: 1 warning 1268s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1268s window/moments/test_moments_consistency_expanding.py: 380 warnings 1268s window/moments/test_moments_consistency_rolling.py: 760 warnings 1268s window/test_api.py: 937 warnings 1268s window/test_apply.py: 82 warnings 1268s window/test_base_indexer.py: 228 warnings 1268s window/test_cython_aggregations.py: 72 warnings 1268s window/test_dtypes.py: 2580 warnings 1268s window/test_ewm.py: 283 warnings 1268s window/test_expanding.py: 333 warnings 1268s window/test_groupby.py: 115 warnings 1268s window/test_numba.py: 51 warnings 1268s window/test_pairwise.py: 312 warnings 1268s window/test_rolling.py: 888 warnings 1268s window/test_rolling_functions.py: 418 warnings 1268s window/test_rolling_quantile.py: 186 warnings 1268s window/test_rolling_skew_kurt.py: 68 warnings 1268s window/test_timeseries_window.py: 83 warnings 1268s window/test_win_type.py: 287 warnings 1268s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=13101) is multi-threaded, use of fork() may lead to deadlocks in the child. 1268s pid = os.fork() 1268s 1268s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1268s /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-7jdmx_1c' 1268s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1268s 1268s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1268s /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-nfbkequw' 1268s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1268s 1268s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1268s = 9064 passed, 793 skipped, 536 deselected, 55 xfailed, 9314 warnings in 329.12s (0:05:29) = 1269s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1269s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1269s 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" 1269s 1269s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1270s ============================= test session starts ============================== 1270s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1270s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1270s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1270s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 1270s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1270s collected 366 items 1270s 1281s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 1284s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 1289s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 1293s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 1296s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 1296s 1296s =================================== FAILURES =================================== 1296s ___________________________ test_complibs[blosc2-1] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 1296s lvl = 1, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-2] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 1296s lvl = 2, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-3] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 1296s lvl = 3, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-4] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 1296s lvl = 4, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-5] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 1296s lvl = 5, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-6] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 1296s lvl = 6, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-7] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 1296s lvl = 7, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-8] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 1296s lvl = 8, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ___________________________ test_complibs[blosc2-9] ____________________________ 1296s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 1296s lvl = 9, lib = 'blosc2' 1296s request = > 1296s 1296s @pytest.mark.parametrize("lvl", range(10)) 1296s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1296s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1296s @pytest.mark.skipif( 1296s not PY311 and is_ci_environment() and is_platform_linux(), 1296s reason="Segfaulting in a CI environment" 1296s # with xfail, would sometimes raise UnicodeDecodeError 1296s # invalid state byte 1296s ) 1296s def test_complibs(tmp_path, lvl, lib, request): 1296s # GH14478 1296s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1296s request.applymarker( 1296s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1296s ) 1296s df = DataFrame( 1296s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1296s ) 1296s 1296s # Remove lzo if its not available on this platform 1296s if not tables.which_lib_version("lzo"): 1296s pytest.skip("lzo not available") 1296s # Remove bzip2 if its not available on this platform 1296s if not tables.which_lib_version("bzip2"): 1296s pytest.skip("bzip2 not available") 1296s 1296s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1296s gname = f"{lvl}_{lib}" 1296s 1296s # Write and read file to see if data is consistent 1296s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1296s result = read_hdf(tmpfile, gname) 1296s tm.assert_frame_equal(result, df) 1296s 1296s # Open file and check metadata for correct amount of compression 1296s with tables.open_file(tmpfile, mode="r") as h5table: 1296s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1296s assert node.filters.complevel == lvl 1296s if lvl == 0: 1296s assert node.filters.complib is None 1296s else: 1296s > assert node.filters.complib == lib 1296s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1296s E 1296s E - blosc2 1296s E + blosc2:blosclz 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1296s ______________________ test_append_frame_column_oriented _______________________ 1296s self = 1296s node = , kwargs = {'side': 'right'} 1296s value = 1296s slobj = slice(0, 4, None) 1296s 1296s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1296s # only allow simple subscripts 1296s 1296s value = self.visit(node.value) 1296s slobj = self.visit(node.slice) 1296s try: 1296s value = value.value 1296s except AttributeError: 1296s pass 1296s 1296s if isinstance(slobj, Term): 1296s # In py39 np.ndarray lookups with Term containing int raise 1296s slobj = slobj.value 1296s 1296s try: 1296s > return self.const_type(value[slobj], self.env) 1296s E TypeError: 'builtin_function_or_method' object is not subscriptable 1296s 1296s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 1296s 1296s The above exception was the direct cause of the following exception: 1296s 1296s setup_path = 'tmp.__aae3374a-927f-45b9-b223-f56c5ddf0d68__.h5' 1296s 1296s @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) 1296s def test_append_frame_column_oriented(setup_path): 1296s with ensure_clean_store(setup_path) as store: 1296s # column oriented 1296s df = DataFrame( 1296s np.random.default_rng(2).standard_normal((10, 4)), 1296s columns=Index(list("ABCD"), dtype=object), 1296s index=date_range("2000-01-01", periods=10, freq="B"), 1296s ) 1296s df.index = df.index._with_freq(None) # freq doesn't round-trip 1296s 1296s _maybe_remove(store, "df1") 1296s store.append("df1", df.iloc[:, :2], axes=["columns"]) 1296s store.append("df1", df.iloc[:, 2:]) 1296s tm.assert_frame_equal(store["df1"], df) 1296s 1296s result = store.select("df1", "columns=A") 1296s expected = df.reindex(columns=["A"]) 1296s tm.assert_frame_equal(expected, result) 1296s 1296s # selection on the non-indexable 1296s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 1296s 1296s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 1296s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1296s return it.get_result() 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1296s results = self.func(self.start, self.stop, where) 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1296s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1296s result = self._read_axes(where=where, start=start, stop=stop) 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1296s selection = Selection(self, where=where, start=start, stop=stop) 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1296s self.terms = self.generate(where) 1296s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1296s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1296s self.terms = self.parse() 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1296s return self._visitor.visit(self.expr) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1296s return self.visit(expr, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1296s return self.visit(node.value, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 1296s return reduce(visitor, operands) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 1296s rhs = self._try_visit_binop(y) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 1296s return self.visit(bop) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1296s return self.visit(binop) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1296s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1296s right = self.visit(node.right, side="right") 1296s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1296s return visitor(node, **kwargs) 1296s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1296s 1296s self = 1296s node = , kwargs = {'side': 'right'} 1296s value = 1296s slobj = slice(0, 4, None) 1296s 1296s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1296s # only allow simple subscripts 1296s 1296s value = self.visit(node.value) 1296s slobj = self.visit(node.slice) 1296s try: 1296s value = value.value 1296s except AttributeError: 1296s pass 1296s 1296s if isinstance(slobj, Term): 1296s # In py39 np.ndarray lookups with Term containing int raise 1296s slobj = slobj.value 1296s 1296s try: 1296s return self.const_type(value[slobj], self.env) 1296s except TypeError as err: 1296s > raise ValueError( 1296s f"cannot subscript {repr(value)} with {repr(slobj)}" 1296s ) from err 1296s E ValueError: cannot subscript with slice(0, 4, None) 1296s 1297s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 1297s __________________________ test_select_filter_corner ___________________________ 1297s setup_path = 'tmp.__c155832a-3e4a-4e99-8276-536768bfca25__.h5' 1297s 1297s @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) 1297s def test_select_filter_corner(setup_path): 1297s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 1297s df.index = [f"{c:3d}" for c in df.index] 1297s df.columns = [f"{c:3d}" for c in df.columns] 1297s 1297s with ensure_clean_store(setup_path) as store: 1297s store.put("frame", df, format="table") 1297s 1297s crit = "columns=df.columns[:75]" 1297s > result = store.select("frame", [crit]) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1297s return it.get_result() 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1297s results = self.func(self.start, self.stop, where) 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1297s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1297s result = self._read_axes(where=where, start=start, stop=stop) 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1297s selection = Selection(self, where=where, start=start, stop=stop) 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1297s self.terms = self.generate(where) 1297s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1297s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1297s self.terms = self.parse() 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1297s return self._visitor.visit(self.expr) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1297s return self.visit(expr, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1297s return self.visit(node.value, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1297s return self.visit(binop) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1297s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1297s right = self.visit(node.right, side="right") 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 1297s value = self.visit(node.value) 1297s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1297s return visitor(node, **kwargs) 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s self = 1297s node = , kwargs = {}, attr = 'columns' 1297s value = , ctx = 1297s resolved = 'df' 1297s 1297s def visit_Attribute(self, node, **kwargs): 1297s attr = node.attr 1297s value = node.value 1297s 1297s ctx = type(node.ctx) 1297s if ctx == ast.Load: 1297s # resolve the value 1297s resolved = self.visit(value) 1297s 1297s # try to get the value to see if we are another expression 1297s try: 1297s resolved = resolved.value 1297s except AttributeError: 1297s pass 1297s 1297s try: 1297s return self.term_type(getattr(resolved, attr), self.env) 1297s except AttributeError: 1297s # something like datetime.datetime where scope is overridden 1297s if isinstance(value, ast.Name) and value.id == attr: 1297s return resolved 1297s 1297s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 1297s E ValueError: Invalid Attribute context Load 1297s 1297s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 1297s __________________ test_frame_setitem_dask_array_into_new_col __________________ 1297s @pytest.mark.xfail( 1297s condition=True,#not IS64, 1297s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 1297s strict=False, 1297s ) 1297s def test_frame_setitem_dask_array_into_new_col(): 1297s # GH#47128 1297s 1297s # dask sets "compute.use_numexpr" to False, so catch the current value 1297s # and ensure to reset it afterwards to avoid impacting other tests 1297s olduse = pd.get_option("compute.use_numexpr") 1297s 1297s try: 1297s da = td.versioned_importorskip("dask.array") 1297s 1297s dda = da.array([1, 2]) 1297s df = DataFrame({"a": ["a", "b"]}) 1297s df["b"] = dda 1297s df["c"] = dda 1297s df.loc[[False, True], "b"] = 100 1297s result = df.loc[[1], :] 1297s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 1297s > tm.assert_frame_equal(result, expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = array([100]), right = array([2]), err_msg = None 1297s 1297s def _raise(left, right, err_msg) -> NoReturn: 1297s if err_msg is None: 1297s if left.shape != right.shape: 1297s raise_assert_detail( 1297s obj, f"{obj} shapes are different", left.shape, right.shape 1297s ) 1297s 1297s diff = 0 1297s for left_arr, right_arr in zip(left, right): 1297s # count up differences 1297s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 1297s diff += 1 1297s 1297s diff = diff * 100.0 / left.size 1297s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 1297s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 1297s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 1297s E 1297s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 1297s E [index]: [1] 1297s E [left]: [100] 1297s E [right]: [2] 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 1297s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 1297s self = 1297s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1297s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 1297s dtype='datetime64[ns, US/Pacific]', freq='D') 1297s df = bar a b c ... f g h 1297s foo .....03 00:00:00-05:00 1297s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 1297s 1297s [4 rows x 8 columns] 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1297s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1297s dtype='object', name='foo') 1297s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1297s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1297s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1297s obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s > assert_class_equal(left, right, exact=exact, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E DataFrame.index classes are different 1297s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1297s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1297s E dtype='object', name='foo') 1297s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1297s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1297s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1297s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 1297s self = 1297s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 1297s df = bar a b c d e f g h 1297s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s E AssertionError: DataFrame are different 1297s E 1297s E DataFrame shape mismatch 1297s E [left]: (8, 8) 1297s E [right]: (4, 8) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1297s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 1297s self = 1297s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 1297s df = bar a b c d e f g h 1297s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s E AssertionError: DataFrame are different 1297s E 1297s E DataFrame shape mismatch 1297s E [left]: (8, 8) 1297s E [right]: (4, 8) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1297s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 1297s self = 1297s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 1297s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 1297s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 1297s df = bar a b c d e f g h 1297s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1297s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1297s obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s > assert_class_equal(left, right, exact=exact, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E DataFrame.index classes are different 1297s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1297s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1297s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 1297s self = 1297s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 1297s df = bar a b c d e f g h 1297s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s E AssertionError: DataFrame are different 1297s E 1297s E DataFrame shape mismatch 1297s E [left]: (8, 8) 1297s E [right]: (4, 8) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1297s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 1297s self = 1297s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1297s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1297s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1297s dtype='Int64') 1297s df = bar a b c d e f g h 1297s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1297s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s assert_class_equal(left, right, exact=exact, obj=obj) 1297s assert_attr_equal("inferred_type", left, right, obj=obj) 1297s 1297s # Skip exact dtype checking when `check_categorical` is False 1297s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1297s right.dtype, CategoricalDtype 1297s ): 1297s if check_categorical: 1297s assert_attr_equal("dtype", left, right, obj=obj) 1297s assert_index_equal(left.categories, right.categories, exact=exact) 1297s return 1297s 1297s > assert_attr_equal("dtype", left, right, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E Attribute "dtype" are different 1297s E [left]: object 1297s E [right]: Int64 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1297s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 1297s self = 1297s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1297s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1297s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1297s dtype='UInt16') 1297s df = bar a b c d e f g h 1297s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1297s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s assert_class_equal(left, right, exact=exact, obj=obj) 1297s assert_attr_equal("inferred_type", left, right, obj=obj) 1297s 1297s # Skip exact dtype checking when `check_categorical` is False 1297s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1297s right.dtype, CategoricalDtype 1297s ): 1297s if check_categorical: 1297s assert_attr_equal("dtype", left, right, obj=obj) 1297s assert_index_equal(left.categories, right.categories, exact=exact) 1297s return 1297s 1297s > assert_attr_equal("dtype", left, right, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E Attribute "dtype" are different 1297s E [left]: object 1297s E [right]: UInt16 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1297s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 1297s self = 1297s 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, 1297s 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, 1297s 96.0, 97.0, 98.0, 99.0], 1297s dtype='Float32') 1297s df = bar a b c d e f g h 1297s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 1297s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 1297s obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s assert_class_equal(left, right, exact=exact, obj=obj) 1297s assert_attr_equal("inferred_type", left, right, obj=obj) 1297s 1297s # Skip exact dtype checking when `check_categorical` is False 1297s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1297s right.dtype, CategoricalDtype 1297s ): 1297s if check_categorical: 1297s assert_attr_equal("dtype", left, right, obj=obj) 1297s assert_index_equal(left.categories, right.categories, exact=exact) 1297s return 1297s 1297s > assert_attr_equal("dtype", left, right, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E Attribute "dtype" are different 1297s E [left]: object 1297s E [right]: Float32 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1297s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 1297s self = 1297s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 1297s True, True, True, True, True,...rue, True, True, 1297s True, True, True, True, True, True, True, True, True, True], 1297s dtype='boolean') 1297s df = bar a b c d e f g h 1297s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s E AssertionError: DataFrame are different 1297s E 1297s E DataFrame shape mismatch 1297s E [left]: (10, 8) 1297s E [right]: (4, 8) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1297s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 1297s self = 1297s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 1297s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 1297s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 1297s dtype='string') 1297s df = bar a b c d e f g h 1297s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1297s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1297s using_infer_string = False 1297s 1297s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1297s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1297s index = index_flat 1297s # MultiIndex is tested in test_to_xarray_with_multiindex 1297s if len(index) == 0: 1297s pytest.skip("Test doesn't make sense for empty index") 1297s 1297s from xarray import Dataset 1297s 1297s df.index = index[:4] 1297s df.index.name = "foo" 1297s df.columns.name = "bar" 1297s result = df.to_xarray() 1297s assert result.sizes["foo"] == 4 1297s assert len(result.coords) == 1 1297s assert len(result.data_vars) == 8 1297s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1297s assert isinstance(result, Dataset) 1297s 1297s # idempotency 1297s # datetimes w/tz are preserved 1297s # column names are lost 1297s expected = df.copy() 1297s # breaks in xarray >= 2024.10.0(?) 1297s # debug print 1297s r0 = result.to_dataframe() 1297s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1297s expected.columns.name = None 1297s > tm.assert_frame_equal(result.to_dataframe(), expected) 1297s 1297s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1297s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1297s 1297s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 1297s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 1297s obj = 'DataFrame.index' 1297s 1297s def _check_types(left, right, obj: str = "Index") -> None: 1297s if not exact: 1297s return 1297s 1297s assert_class_equal(left, right, exact=exact, obj=obj) 1297s assert_attr_equal("inferred_type", left, right, obj=obj) 1297s 1297s # Skip exact dtype checking when `check_categorical` is False 1297s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1297s right.dtype, CategoricalDtype 1297s ): 1297s if check_categorical: 1297s assert_attr_equal("dtype", left, right, obj=obj) 1297s assert_index_equal(left.categories, right.categories, exact=exact) 1297s return 1297s 1297s > assert_attr_equal("dtype", left, right, obj=obj) 1297s E AssertionError: DataFrame.index are different 1297s E 1297s E Attribute "dtype" are different 1297s E [left]: object 1297s E [right]: string[python] 1297s 1297s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1297s =============================== warnings summary =============================== 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 1297s /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 1297s pytestmark = pytest.mark.single_cpu 1297s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 1297s /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 1297s pytestmark = pytest.mark.single_cpu 1297s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 1297s /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 1297s pytestmark = pytest.mark.single_cpu 1297s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 1297s /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 1297s @pytest.mark.single_cpu 1297s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 1297s /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 1297s @pytest.mark.single_cpu 1297s 1297s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 1297s /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 1297s @pytest.mark.single_cpu 1297s 1297s io/pytables/test_file_handling.py: 191 warnings 1297s io/pytables/test_append.py: 21 warnings 1297s io/pytables/test_store.py: 66 warnings 1297s test_downstream.py: 26 warnings 1297s generic/test_to_xarray.py: 62 warnings 1297s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=23040) is multi-threaded, use of fork() may lead to deadlocks in the child. 1297s pid = os.fork() 1297s 1297s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1297s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-4n8_5t4l' 1297s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1297s 1297s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1297s /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-_lvp2l_i' 1297s config.cache.set("cache/lastfailed", self.lastfailed) 1297s 1297s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1297s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-4irj5qta' 1297s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1297s 1297s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1297s =========================== short test summary info ============================ 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 1297s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 1297s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 27.26s =========== 1297s pymysql/psycopg2 tests, which do not work in this test environment 1297s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1297s 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" 1297s 1297s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1298s ============================= test session starts ============================== 1298s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1298s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1298s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1298s plugins: forked-1.6.0, qt-4.4.0, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, localserver-0.9.0.post0, xdist-3.6.1 1298s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1298s collected 2513 items 1298s 1835s ../../../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................ 1860s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1860s 1860s ==================================== ERRORS ==================================== 1860s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s > sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3.13/socket.py:864: in create_connection 1860s raise exceptions[0] 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s address = ('localhost', 3306), timeout = 10, source_address = None 1860s 1860s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1860s source_address=None, *, all_errors=False): 1860s """Connect to *address* and return the socket object. 1860s 1860s Convenience function. Connect to *address* (a 2-tuple ``(host, 1860s port)``) and return the socket object. Passing the optional 1860s *timeout* parameter will set the timeout on the socket instance 1860s before attempting to connect. If no *timeout* is supplied, the 1860s global default timeout setting returned by :func:`getdefaulttimeout` 1860s is used. If *source_address* is set it must be a tuple of (host, port) 1860s for the socket to bind as a source address before making the connection. 1860s A host of '' or port 0 tells the OS to use the default. When a connection 1860s cannot be created, raises the last error if *all_errors* is False, 1860s and an ExceptionGroup of all errors if *all_errors* is True. 1860s """ 1860s 1860s host, port = address 1860s exceptions = [] 1860s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1860s af, socktype, proto, canonname, sa = res 1860s sock = None 1860s try: 1860s sock = socket(af, socktype, proto) 1860s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1860s sock.settimeout(timeout) 1860s if source_address: 1860s sock.bind(source_address) 1860s > sock.connect(sa) 1860s E ConnectionRefusedError: [Errno 111] Connection refused 1860s 1860s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1860s 1860s During handling of the above exception, another exception occurred: 1860s 1860s self = 1860s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1860s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def mysql_pymysql_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s pymysql = td.versioned_importorskip("pymysql") 1860s engine = sqlalchemy.create_engine( 1860s "mysql+pymysql://root@localhost:3306/pandas", 1860s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1860s self.connect() 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s self = , sock = None 1860s 1860s def connect(self, sock=None): 1860s self._closed = False 1860s try: 1860s if sock is None: 1860s if self.unix_socket: 1860s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1860s sock.settimeout(self.connect_timeout) 1860s sock.connect(self.unix_socket) 1860s self.host_info = "Localhost via UNIX socket" 1860s self._secure = True 1860s if DEBUG: 1860s print("connected using unix_socket") 1860s else: 1860s kwargs = {} 1860s if self.bind_address is not None: 1860s kwargs["source_address"] = (self.bind_address, 0) 1860s while True: 1860s try: 1860s sock = socket.create_connection( 1860s (self.host, self.port), self.connect_timeout, **kwargs 1860s ) 1860s break 1860s except OSError as e: 1860s if e.errno == errno.EINTR: 1860s continue 1860s raise 1860s self.host_info = "socket %s:%d" % (self.host, self.port) 1860s if DEBUG: 1860s print("connected using socket") 1860s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1860s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1860s sock.settimeout(None) 1860s 1860s self._sock = sock 1860s self._rfile = sock.makefile("rb") 1860s self._next_seq_id = 0 1860s 1860s self._get_server_information() 1860s self._request_authentication() 1860s 1860s # Send "SET NAMES" query on init for: 1860s # - Ensure charaset (and collation) is set to the server. 1860s # - collation_id in handshake packet may be ignored. 1860s # - If collation is not specified, we don't know what is server's 1860s # default collation for the charset. For example, default collation 1860s # of utf8mb4 is: 1860s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1860s # - MySQL 8.0: utf8mb4_0900_ai_ci 1860s # 1860s # Reference: 1860s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1860s # - https://github.com/wagtail/wagtail/issues/9477 1860s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1860s self.set_character_set(self.charset, self.collation) 1860s 1860s if self.sql_mode is not None: 1860s c = self.cursor() 1860s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1860s c.close() 1860s 1860s if self.init_command is not None: 1860s c = self.cursor() 1860s c.execute(self.init_command) 1860s c.close() 1860s 1860s if self.autocommit_mode is not None: 1860s self.autocommit(self.autocommit_mode) 1860s except BaseException as e: 1860s self._rfile = None 1860s if sock is not None: 1860s try: 1860s sock.close() 1860s except: # noqa 1860s pass 1860s 1860s if isinstance(e, (OSError, IOError)): 1860s exc = err.OperationalError( 1860s CR.CR_CONN_HOST_ERROR, 1860s f"Can't connect to MySQL server on {self.host!r} ({e})", 1860s ) 1860s # Keep original exception and traceback to investigate error. 1860s exc.original_exception = e 1860s exc.traceback = traceback.format_exc() 1860s if DEBUG: 1860s print(exc.traceback) 1860s > raise exc 1860s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1860s engine.connect().close() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1860s return self._connection_cls(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1860s Connection._handle_dbapi_exception_noconnection( 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1860s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1860s self._dbapi_connection = engine.raw_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E 1860s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1860s self = 1860s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1860s connection = None, _has_events = None, _allow_revalidate = True 1860s _allow_autobegin = True 1860s 1860s def __init__( 1860s self, 1860s engine: Engine, 1860s connection: Optional[PoolProxiedConnection] = None, 1860s _has_events: Optional[bool] = None, 1860s _allow_revalidate: bool = True, 1860s _allow_autobegin: bool = True, 1860s ): 1860s """Construct a new Connection.""" 1860s self.engine = engine 1860s self.dialect = dialect = engine.dialect 1860s 1860s if connection is None: 1860s try: 1860s > self._dbapi_connection = engine.raw_connection() 1860s 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1860s return self.pool.connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1860s return _ConnectionFairy._checkout(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1860s fairy = _ConnectionRecord.checkout(pool) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1860s rec = pool._do_get() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1860s return self._create_connection() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1860s return _ConnectionRecord(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1860s self.__connect() 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1860s with util.safe_reraise(): 1860s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1860s raise exc_value.with_traceback(exc_tb) 1860s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1860s self.dbapi_connection = connection = pool._invoke_creator(self) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1860s return dialect.connect(*cargs, **cparams) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1860s return self.loaded_dbapi.connect(*cargs, **cparams) 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s 1860s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1860s connection_factory = None, cursor_factory = None 1860s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1860s kwasync = {} 1860s 1860s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1860s """ 1860s Create a new database connection. 1860s 1860s The connection parameters can be specified as a string: 1860s 1860s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1860s 1860s or using a set of keyword arguments: 1860s 1860s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1860s 1860s Or as a mix of both. The basic connection parameters are: 1860s 1860s - *dbname*: the database name 1860s - *database*: the database name (only as keyword argument) 1860s - *user*: user name used to authenticate 1860s - *password*: password used to authenticate 1860s - *host*: database host address (defaults to UNIX socket if not provided) 1860s - *port*: connection port number (defaults to 5432 if not provided) 1860s 1860s Using the *connection_factory* parameter a different class or connections 1860s factory can be specified. It should be a callable object taking a dsn 1860s argument. 1860s 1860s Using the *cursor_factory* parameter, a new default cursor factory will be 1860s used by cursor(). 1860s 1860s Using *async*=True an asynchronous connection will be created. *async_* is 1860s a valid alias (for Python versions where ``async`` is a keyword). 1860s 1860s Any other keyword parameter will be passed to the underlying client 1860s library: the list of supported parameters depends on the library version. 1860s 1860s """ 1860s kwasync = {} 1860s if 'async' in kwargs: 1860s kwasync['async'] = kwargs.pop('async') 1860s if 'async_' in kwargs: 1860s kwasync['async_'] = kwargs.pop('async_') 1860s 1860s dsn = _ext.make_dsn(dsn, **kwargs) 1860s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1860s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1860s E Is the server running on that host and accepting TCP/IP connections? 1860s 1860s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1860s 1860s The above exception was the direct cause of the following exception: 1860s 1860s @pytest.fixture 1860s def postgresql_psycopg2_engine(): 1860s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1860s td.versioned_importorskip("psycopg2") 1860s engine = sqlalchemy.create_engine( 1860s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1860s poolclass=sqlalchemy.pool.NullPool, 1860s ) 1860s yield engine 1860s > for view in get_all_views(engine): 1860s 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1860s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1860s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1860s return inspect(conn).get_view_names() 1860s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1860s ret = reg(subject) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1860s return Inspector._construct(Inspector._init_engine, bind) 1860s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1860s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s > sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3.13/socket.py:864: in create_connection 1861s raise exceptions[0] 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s address = ('localhost', 3306), timeout = 10, source_address = None 1861s 1861s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1861s source_address=None, *, all_errors=False): 1861s """Connect to *address* and return the socket object. 1861s 1861s Convenience function. Connect to *address* (a 2-tuple ``(host, 1861s port)``) and return the socket object. Passing the optional 1861s *timeout* parameter will set the timeout on the socket instance 1861s before attempting to connect. If no *timeout* is supplied, the 1861s global default timeout setting returned by :func:`getdefaulttimeout` 1861s is used. If *source_address* is set it must be a tuple of (host, port) 1861s for the socket to bind as a source address before making the connection. 1861s A host of '' or port 0 tells the OS to use the default. When a connection 1861s cannot be created, raises the last error if *all_errors* is False, 1861s and an ExceptionGroup of all errors if *all_errors* is True. 1861s """ 1861s 1861s host, port = address 1861s exceptions = [] 1861s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1861s af, socktype, proto, canonname, sa = res 1861s sock = None 1861s try: 1861s sock = socket(af, socktype, proto) 1861s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1861s sock.settimeout(timeout) 1861s if source_address: 1861s sock.bind(source_address) 1861s > sock.connect(sa) 1861s E ConnectionRefusedError: [Errno 111] Connection refused 1861s 1861s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1861s 1861s During handling of the above exception, another exception occurred: 1861s 1861s self = 1861s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1861s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def mysql_pymysql_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s pymysql = td.versioned_importorskip("pymysql") 1861s engine = sqlalchemy.create_engine( 1861s "mysql+pymysql://root@localhost:3306/pandas", 1861s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1861s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1861s self._dbapi_connection = engine.raw_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1861s self.connect() 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s self = , sock = None 1861s 1861s def connect(self, sock=None): 1861s self._closed = False 1861s try: 1861s if sock is None: 1861s if self.unix_socket: 1861s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1861s sock.settimeout(self.connect_timeout) 1861s sock.connect(self.unix_socket) 1861s self.host_info = "Localhost via UNIX socket" 1861s self._secure = True 1861s if DEBUG: 1861s print("connected using unix_socket") 1861s else: 1861s kwargs = {} 1861s if self.bind_address is not None: 1861s kwargs["source_address"] = (self.bind_address, 0) 1861s while True: 1861s try: 1861s sock = socket.create_connection( 1861s (self.host, self.port), self.connect_timeout, **kwargs 1861s ) 1861s break 1861s except OSError as e: 1861s if e.errno == errno.EINTR: 1861s continue 1861s raise 1861s self.host_info = "socket %s:%d" % (self.host, self.port) 1861s if DEBUG: 1861s print("connected using socket") 1861s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1861s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1861s sock.settimeout(None) 1861s 1861s self._sock = sock 1861s self._rfile = sock.makefile("rb") 1861s self._next_seq_id = 0 1861s 1861s self._get_server_information() 1861s self._request_authentication() 1861s 1861s # Send "SET NAMES" query on init for: 1861s # - Ensure charaset (and collation) is set to the server. 1861s # - collation_id in handshake packet may be ignored. 1861s # - If collation is not specified, we don't know what is server's 1861s # default collation for the charset. For example, default collation 1861s # of utf8mb4 is: 1861s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1861s # - MySQL 8.0: utf8mb4_0900_ai_ci 1861s # 1861s # Reference: 1861s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1861s # - https://github.com/wagtail/wagtail/issues/9477 1861s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1861s self.set_character_set(self.charset, self.collation) 1861s 1861s if self.sql_mode is not None: 1861s c = self.cursor() 1861s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1861s c.close() 1861s 1861s if self.init_command is not None: 1861s c = self.cursor() 1861s c.execute(self.init_command) 1861s c.close() 1861s 1861s if self.autocommit_mode is not None: 1861s self.autocommit(self.autocommit_mode) 1861s except BaseException as e: 1861s self._rfile = None 1861s if sock is not None: 1861s try: 1861s sock.close() 1861s except: # noqa 1861s pass 1861s 1861s if isinstance(e, (OSError, IOError)): 1861s exc = err.OperationalError( 1861s CR.CR_CONN_HOST_ERROR, 1861s f"Can't connect to MySQL server on {self.host!r} ({e})", 1861s ) 1861s # Keep original exception and traceback to investigate error. 1861s exc.original_exception = e 1861s exc.traceback = traceback.format_exc() 1861s if DEBUG: 1861s print(exc.traceback) 1861s > raise exc 1861s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1861s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1861s 1861s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1861s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 1861s self = 1861s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1861s connection = None, _has_events = None, _allow_revalidate = True 1861s _allow_autobegin = True 1861s 1861s def __init__( 1861s self, 1861s engine: Engine, 1861s connection: Optional[PoolProxiedConnection] = None, 1861s _has_events: Optional[bool] = None, 1861s _allow_revalidate: bool = True, 1861s _allow_autobegin: bool = True, 1861s ): 1861s """Construct a new Connection.""" 1861s self.engine = engine 1861s self.dialect = dialect = engine.dialect 1861s 1861s if connection is None: 1861s try: 1861s > self._dbapi_connection = engine.raw_connection() 1861s 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1861s return self.pool.connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1861s return _ConnectionFairy._checkout(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1861s fairy = _ConnectionRecord.checkout(pool) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1861s rec = pool._do_get() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1861s return self._create_connection() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1861s return _ConnectionRecord(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1861s self.__connect() 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1861s with util.safe_reraise(): 1861s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1861s raise exc_value.with_traceback(exc_tb) 1861s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1861s self.dbapi_connection = connection = pool._invoke_creator(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1861s return dialect.connect(*cargs, **cparams) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1861s return self.loaded_dbapi.connect(*cargs, **cparams) 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s 1861s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1861s connection_factory = None, cursor_factory = None 1861s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1861s kwasync = {} 1861s 1861s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1861s """ 1861s Create a new database connection. 1861s 1861s The connection parameters can be specified as a string: 1861s 1861s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1861s 1861s or using a set of keyword arguments: 1861s 1861s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1861s 1861s Or as a mix of both. The basic connection parameters are: 1861s 1861s - *dbname*: the database name 1861s - *database*: the database name (only as keyword argument) 1861s - *user*: user name used to authenticate 1861s - *password*: password used to authenticate 1861s - *host*: database host address (defaults to UNIX socket if not provided) 1861s - *port*: connection port number (defaults to 5432 if not provided) 1861s 1861s Using the *connection_factory* parameter a different class or connections 1861s factory can be specified. It should be a callable object taking a dsn 1861s argument. 1861s 1861s Using the *cursor_factory* parameter, a new default cursor factory will be 1861s used by cursor(). 1861s 1861s Using *async*=True an asynchronous connection will be created. *async_* is 1861s a valid alias (for Python versions where ``async`` is a keyword). 1861s 1861s Any other keyword parameter will be passed to the underlying client 1861s library: the list of supported parameters depends on the library version. 1861s 1861s """ 1861s kwasync = {} 1861s if 'async' in kwargs: 1861s kwasync['async'] = kwargs.pop('async') 1861s if 'async_' in kwargs: 1861s kwasync['async_'] = kwargs.pop('async_') 1861s 1861s dsn = _ext.make_dsn(dsn, **kwargs) 1861s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1861s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1861s E Is the server running on that host and accepting TCP/IP connections? 1861s 1861s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1861s 1861s The above exception was the direct cause of the following exception: 1861s 1861s @pytest.fixture 1861s def postgresql_psycopg2_engine(): 1861s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1861s td.versioned_importorskip("psycopg2") 1861s engine = sqlalchemy.create_engine( 1861s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1861s poolclass=sqlalchemy.pool.NullPool, 1861s ) 1861s yield engine 1861s > for view in get_all_views(engine): 1861s 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1861s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1861s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1861s return inspect(conn).get_view_names() 1861s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1861s ret = reg(subject) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1861s return Inspector._construct(Inspector._init_engine, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1861s init(self, bind) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1861s engine.connect().close() 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1861s return self._connection_cls(self) 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1861s Connection._handle_dbapi_exception_noconnection( 1861s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def mysql_pymysql_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s pymysql = td.versioned_importorskip("pymysql") 1862s engine = sqlalchemy.create_engine( 1862s "mysql+pymysql://root@localhost:3306/pandas", 1862s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ ERROR at teardown of test_self_join_date_columns _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s @pytest.fixture 1862s def postgresql_psycopg2_engine(): 1862s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1862s td.versioned_importorskip("psycopg2") 1862s engine = sqlalchemy.create_engine( 1862s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1862s poolclass=sqlalchemy.pool.NullPool, 1862s ) 1862s yield engine 1862s > for view in get_all_views(engine): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1862s return inspect(conn).get_view_names() 1862s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1862s ret = reg(subject) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1862s return Inspector._construct(Inspector._init_engine, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1862s init(self, bind) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1862s engine.connect().close() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s =================================== FAILURES =================================== 1862s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql(conn, test_frame1, request): 1862s # GH 51086 if conn is sqlite_engine 1862s conn = request.getfixturevalue(conn) 1862s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql(conn, test_frame1, request): 1862s # GH 51086 if conn is sqlite_engine 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql(conn, test_frame1, request): 1862s # GH 51086 if conn is sqlite_engine 1862s conn = request.getfixturevalue(conn) 1862s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql(conn, test_frame1, request): 1862s # GH 51086 if conn is sqlite_engine 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1862s if conn == "postgresql_adbc_conn": 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="postgres ADBC driver cannot insert index with null type", 1862s strict=True, 1862s ) 1862s ) 1862s # GH 51086 if conn is sqlite_engine 1862s conn = request.getfixturevalue(conn) 1862s empty_df = test_frame1.iloc[:0] 1862s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1862s if conn == "postgresql_adbc_conn": 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="postgres ADBC driver cannot insert index with null type", 1862s strict=True, 1862s ) 1862s ) 1862s # GH 51086 if conn is sqlite_engine 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1862s if conn == "postgresql_adbc_conn": 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="postgres ADBC driver cannot insert index with null type", 1862s strict=True, 1862s ) 1862s ) 1862s # GH 51086 if conn is sqlite_engine 1862s conn = request.getfixturevalue(conn) 1862s empty_df = test_frame1.iloc[:0] 1862s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1862s if conn == "postgresql_adbc_conn": 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="postgres ADBC driver cannot insert index with null type", 1862s strict=True, 1862s ) 1862s ) 1862s # GH 51086 if conn is sqlite_engine 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn', method = None 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s method = None 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', method = None 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn', method = 'multi' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s method = 'multi' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', method = 'multi' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("method", [None, "multi"]) 1862s def test_to_sql(conn, method, test_frame1, request): 1862s if method == "multi" and "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'method' not implemented for ADBC drivers", strict=True 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 1862s num_row_coef = 1 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s mode = 'replace', num_row_coef = 1 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 1862s num_row_coef = 2 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s mode = 'append', num_row_coef = 2 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1862s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_exist_fail(conn, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_exist_fail(conn, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_exist_fail(conn, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_exist_fail(conn, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_query_expression_with_parameter(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_query_expression_with_parameter(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_query_expression_with_parameter(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_query_expression_with_parameter(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s for db, query in sql_strings["read_parameters"].items(): 1862s if db in conn: 1862s break 1862s else: 1862s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s for db, query in sql_strings["read_parameters"].items(): 1862s if db in conn: 1862s break 1862s else: 1862s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s for db, query in sql_strings["read_parameters"].items(): 1862s if db in conn: 1862s break 1862s else: 1862s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'chunksize' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s for db, query in sql_strings["read_parameters"].items(): 1862s if db in conn: 1862s break 1862s else: 1862s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table(conn, request): 1862s # GH 51015 if conn = sqlite_iris_str 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table(conn, request): 1862s # GH 51015 if conn = sqlite_iris_str 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table(conn, request): 1862s # GH 51015 if conn = sqlite_iris_str 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table(conn, request): 1862s # GH 51015 if conn = sqlite_iris_str 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1862s def test_read_iris_table_chunksize(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1862s def test_to_sql_callable(conn, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s 1862s check = [] # used to double check function below is really being used 1862s 1862s def sample(pd_table, conn, keys, data_iter): 1862s check.append(1) 1862s data = [dict(zip(keys, row)) for row in data_iter] 1862s conn.execute(pd_table.table.insert(), data) 1862s 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1862s def test_to_sql_callable(conn, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1862s def test_to_sql_callable(conn, test_frame1, request): 1862s conn = request.getfixturevalue(conn) 1862s 1862s check = [] # used to double check function below is really being used 1862s 1862s def sample(pd_table, conn, keys, data_iter): 1862s check.append(1) 1862s data = [dict(zip(keys, row)) for row in data_iter] 1862s conn.execute(pd_table.table.insert(), data) 1862s 1862s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1862s def test_to_sql_callable(conn, test_frame1, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_default_type_conversion(conn, request): 1862s conn_name = conn 1862s if conn_name == "sqlite_buildin_types": 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="sqlite_buildin connection does not implement read_sql_table" 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_default_type_conversion(conn, request): 1862s conn_name = conn 1862s if conn_name == "sqlite_buildin_types": 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="sqlite_buildin connection does not implement read_sql_table" 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_default_type_conversion(conn, request): 1862s conn_name = conn 1862s if conn_name == "sqlite_buildin_types": 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="sqlite_buildin connection does not implement read_sql_table" 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_default_type_conversion(conn, request): 1862s conn_name = conn 1862s if conn_name == "sqlite_buildin_types": 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="sqlite_buildin connection does not implement read_sql_table" 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", mysql_connectable) 1862s def test_read_procedure(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s 1862s # GH 7324 1862s # Although it is more an api test, it is added to the 1862s # mysql tests as sqlite does not have stored procedures 1862s from sqlalchemy import text 1862s from sqlalchemy.engine import Engine 1862s 1862s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 1862s > df.to_sql(name="test_frame", con=conn, index=False) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", mysql_connectable) 1862s def test_read_procedure(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s expected_count = 2 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1862s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1862s # GH 8953 1862s # Example in io.rst found under _io.sql.method 1862s # not available in sqlite, mysql 1862s def psql_insert_copy(table, conn, keys, data_iter): 1862s # gets a DBAPI connection that can provide a cursor 1862s dbapi_conn = conn.connection 1862s with dbapi_conn.cursor() as cur: 1862s s_buf = StringIO() 1862s writer = csv.writer(s_buf) 1862s writer.writerows(data_iter) 1862s s_buf.seek(0) 1862s 1862s columns = ", ".join([f'"{k}"' for k in keys]) 1862s if table.schema: 1862s table_name = f"{table.schema}.{table.name}" 1862s else: 1862s table_name = table.name 1862s 1862s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1862s cur.copy_expert(sql=sql_query, file=s_buf) 1862s return expected_count 1862s 1862s conn = request.getfixturevalue(conn) 1862s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1862s > result_count = expected.to_sql( 1862s name="test_frame", con=conn, index=False, method=psql_insert_copy 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', expected_count = 2 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1862s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1862s # GH 8953 1862s # Example in io.rst found under _io.sql.method 1862s # not available in sqlite, mysql 1862s def psql_insert_copy(table, conn, keys, data_iter): 1862s # gets a DBAPI connection that can provide a cursor 1862s dbapi_conn = conn.connection 1862s with dbapi_conn.cursor() as cur: 1862s s_buf = StringIO() 1862s writer = csv.writer(s_buf) 1862s writer.writerows(data_iter) 1862s s_buf.seek(0) 1862s 1862s columns = ", ".join([f'"{k}"' for k in keys]) 1862s if table.schema: 1862s table_name = f"{table.schema}.{table.name}" 1862s else: 1862s table_name = table.name 1862s 1862s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1862s cur.copy_expert(sql=sql_query, file=s_buf) 1862s return expected_count 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s expected_count = 'Success!' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1862s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1862s # GH 8953 1862s # Example in io.rst found under _io.sql.method 1862s # not available in sqlite, mysql 1862s def psql_insert_copy(table, conn, keys, data_iter): 1862s # gets a DBAPI connection that can provide a cursor 1862s dbapi_conn = conn.connection 1862s with dbapi_conn.cursor() as cur: 1862s s_buf = StringIO() 1862s writer = csv.writer(s_buf) 1862s writer.writerows(data_iter) 1862s s_buf.seek(0) 1862s 1862s columns = ", ".join([f'"{k}"' for k in keys]) 1862s if table.schema: 1862s table_name = f"{table.schema}.{table.name}" 1862s else: 1862s table_name = table.name 1862s 1862s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1862s cur.copy_expert(sql=sql_query, file=s_buf) 1862s return expected_count 1862s 1862s conn = request.getfixturevalue(conn) 1862s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1862s > result_count = expected.to_sql( 1862s name="test_frame", con=conn, index=False, method=psql_insert_copy 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1862s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1862s # GH 8953 1862s # Example in io.rst found under _io.sql.method 1862s # not available in sqlite, mysql 1862s def psql_insert_copy(table, conn, keys, data_iter): 1862s # gets a DBAPI connection that can provide a cursor 1862s dbapi_conn = conn.connection 1862s with dbapi_conn.cursor() as cur: 1862s s_buf = StringIO() 1862s writer = csv.writer(s_buf) 1862s writer.writerows(data_iter) 1862s s_buf.seek(0) 1862s 1862s columns = ", ".join([f'"{k}"' for k in keys]) 1862s if table.schema: 1862s table_name = f"{table.schema}.{table.name}" 1862s else: 1862s table_name = table.name 1862s 1862s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1862s cur.copy_expert(sql=sql_query, file=s_buf) 1862s return expected_count 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s def test_insertion_method_on_conflict_do_nothing(conn, request): 1862s # GH 15988: Example in to_sql docstring 1862s conn = request.getfixturevalue(conn) 1862s 1862s from sqlalchemy.dialects.postgresql import insert 1862s from sqlalchemy.engine import Engine 1862s from sqlalchemy.sql import text 1862s 1862s def insert_on_conflict(table, conn, keys, data_iter): 1862s data = [dict(zip(keys, row)) for row in data_iter] 1862s stmt = ( 1862s insert(table.table) 1862s .values(data) 1862s .on_conflict_do_nothing(index_elements=["a"]) 1862s ) 1862s result = conn.execute(stmt) 1862s return result.rowcount 1862s 1862s create_sql = text( 1862s """ 1862s CREATE TABLE test_insert_conflict ( 1862s a integer PRIMARY KEY, 1862s b numeric, 1862s c text 1862s ); 1862s """ 1862s ) 1862s if isinstance(conn, Engine): 1862s > with conn.connect() as con: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s def test_insertion_method_on_conflict_do_nothing(conn, request): 1862s # GH 15988: Example in to_sql docstring 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_on_public_schema(conn, request): 1862s if "sqlite" in conn or "mysql" in conn: 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="test for public schema only specific to postgresql" 1862s ) 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s 1862s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 1862s > test_data.to_sql( 1862s name="test_public_schema", 1862s con=conn, 1862s if_exists="append", 1862s index=False, 1862s schema="public", 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_to_sql_on_public_schema(conn, request): 1862s if "sqlite" in conn or "mysql" in conn: 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="test for public schema only specific to postgresql" 1862s ) 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", mysql_connectable) 1862s def test_insertion_method_on_conflict_update(conn, request): 1862s # GH 14553: Example in to_sql docstring 1862s conn = request.getfixturevalue(conn) 1862s 1862s from sqlalchemy.dialects.mysql import insert 1862s from sqlalchemy.engine import Engine 1862s from sqlalchemy.sql import text 1862s 1862s def insert_on_conflict(table, conn, keys, data_iter): 1862s data = [dict(zip(keys, row)) for row in data_iter] 1862s stmt = insert(table.table).values(data) 1862s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 1862s result = conn.execute(stmt) 1862s return result.rowcount 1862s 1862s create_sql = text( 1862s """ 1862s CREATE TABLE test_insert_conflict ( 1862s a INT PRIMARY KEY, 1862s b FLOAT, 1862s c VARCHAR(10) 1862s ); 1862s """ 1862s ) 1862s if isinstance(conn, Engine): 1862s > with conn.connect() as con: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", mysql_connectable) 1862s def test_insertion_method_on_conflict_update(conn, request): 1862s # GH 14553: Example in to_sql docstring 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s def test_read_view_postgres(conn, request): 1862s # GH 52969 1862s conn = request.getfixturevalue(conn) 1862s 1862s from sqlalchemy.engine import Engine 1862s from sqlalchemy.sql import text 1862s 1862s table_name = f"group_{uuid.uuid4().hex}" 1862s view_name = f"group_view_{uuid.uuid4().hex}" 1862s 1862s sql_stmt = text( 1862s f""" 1862s CREATE TABLE {table_name} ( 1862s group_id INTEGER, 1862s name TEXT 1862s ); 1862s INSERT INTO {table_name} VALUES 1862s (1, 'name'); 1862s CREATE VIEW {view_name} 1862s AS 1862s SELECT * FROM {table_name}; 1862s """ 1862s ) 1862s if isinstance(conn, Engine): 1862s > with conn.connect() as con: 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", postgresql_connectable) 1862s def test_read_view_postgres(conn, request): 1862s # GH 52969 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 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=?'}} 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'params' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_view(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_view(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_view(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_view(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_with_chunksize_no_result(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_with_chunksize_no_result(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_with_chunksize_no_result(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_read_sql_with_chunksize_no_result(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame1", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame1", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_fail(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame2", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_fail(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_fail(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame2", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_fail(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_replace(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame3", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_replace(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_replace(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame3", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_replace(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_append(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame4", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_append(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_append(conn, request, test_frame1): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame4", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_append(conn, request, test_frame1): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame3 = index A B 1862s 0 2000-01-03 00:00:00 2147483647 -1.987670 1862s 1 2000-01-04 00:00:00 -29 -0.041232 1862s 2 2000-01-05 00:00:00 20000 0.731168 1862s 3 2000-01-06 00:00:00 -290867 1.567621 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame5", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame3 = index A B 1862s 0 2000-01-03 00:00:00 2147483647 -1.987670 1862s 1 2000-01-04 00:00:00 -29 -0.041232 1862s 2 2000-01-05 00:00:00 20000 0.731168 1862s 3 2000-01-06 00:00:00 -290867 1.567621 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame3 = index A B 1862s 0 2000-01-03 00:00:00 2147483647 -1.987670 1862s 1 2000-01-04 00:00:00 -29 -0.041232 1862s 2 2000-01-05 00:00:00 20000 0.731168 1862s 3 2000-01-06 00:00:00 -290867 1.567621 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame5", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame3 = index A B 1862s 0 2000-01-03 00:00:00 2147483647 -1.987670 1862s 1 2000-01-04 00:00:00 -29 -0.041232 1862s 2 2000-01-05 00:00:00 20000 0.731168 1862s 3 2000-01-06 00:00:00 -290867 1.567621 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_series(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_series", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_series(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_series(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_series", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_series(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip(conn, request, test_frame1): 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip(conn, request, test_frame1): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip(conn, request, test_frame1): 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip(conn, request, test_frame1): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_frame_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_execute_sql(conn, request): 1862s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_execute_sql(conn, request): 1862s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1862s create_and_load_iris(mysql_pymysql_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_execute_sql(conn, request): 1862s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_iris' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_iris) 1862s def test_api_execute_sql(conn, request): 1862s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1862s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1862s with conn.begin() as con: 1862s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1862s return next(self.gen) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1862s with self.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_parsing(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_parsing(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_parsing(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_parsing(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'SELECT * FROM types' 1862s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = 1862s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1862s error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'ignore' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'raise' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s read_sql = , text = 'types' 1862s mode = 'sqlalchemy', error = 'coerce' 1862s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1862s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1862s 1 first 2000-01-04 00:00:00 ... NaN NaN 1862s 1862s [2 rows x 9 columns] 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1862s @pytest.mark.parametrize( 1862s "read_sql, text, mode", 1862s [ 1862s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1862s (sql.read_sql, "types", ("sqlalchemy")), 1862s ( 1862s sql.read_sql_query, 1862s "SELECT * FROM types", 1862s ("sqlalchemy", "fallback"), 1862s ), 1862s (sql.read_sql_table, "types", ("sqlalchemy")), 1862s ], 1862s ) 1862s def test_api_custom_dateparsing_error( 1862s conn, request, read_sql, text, mode, error, types_data_frame 1862s ): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_and_index(conn, request): 1862s # Test case where same column appears in parse_date and index_col 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_and_index(conn, request): 1862s # Test case where same column appears in parse_date and index_col 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1862s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_engine_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_and_index(conn, request): 1862s # Test case where same column appears in parse_date and index_col 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn_types' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable_types) 1862s def test_api_date_and_index(conn, request): 1862s # Test case where same column appears in parse_date and index_col 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1862s fixturedef = request._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1862s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1862s with conn.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_timedelta(conn, request): 1862s # see #6921 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_timedelta", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_timedelta(conn, request): 1862s # see #6921 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_timedelta(conn, request): 1862s # see #6921 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_timedelta", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_timedelta(conn, request): 1862s # see #6921 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_complex_raises(conn, request): 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s df = DataFrame({"a": [1 + 1j, 2j]}) 1862s 1862s if "adbc" in conn_name: 1862s msg = "datatypes not supported" 1862s else: 1862s msg = "Complex datatypes not supported" 1862s with pytest.raises(ValueError, match=msg): 1862s > assert df.to_sql("test_complex", con=conn) is None 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_complex_raises(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_complex_raises(conn, request): 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s df = DataFrame({"a": [1 + 1j, 2j]}) 1862s 1862s if "adbc" in conn_name: 1862s msg = "datatypes not supported" 1862s else: 1862s msg = "Complex datatypes not supported" 1862s with pytest.raises(ValueError, match=msg): 1862s > assert df.to_sql("test_complex", con=conn) is None 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1862s return func(*args, **kwargs) 1862s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1862s return sql.to_sql( 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_complex_raises(conn, request): 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = None, index_label = None, expected = 'index' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = None, index_label = None, expected = 'index' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = None, index_label = None, expected = 'index' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = None, index_label = None, expected = 'index' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = None, index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = None, index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = None, index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = None, index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = 'index_name', index_label = None, expected = 'index_name' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = 'index_name', index_label = None, expected = 'index_name' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = 'index_name', index_label = None, expected = 'index_name' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = 'index_name', index_label = None, expected = 'index_name' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = 0, index_label = None, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = 0, index_label = None, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = 0, index_label = None, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = 0, index_label = None, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s index_name = None, index_label = 0, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s index_name = None, index_label = 0, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s index_name = None, index_label = 0, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s index_name = None, index_label = 0, expected = '0' 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "index_name,index_label,expected", 1862s [ 1862s # no index name, defaults to 'index' 1862s (None, None, "index"), 1862s # specifying index_label 1862s (None, "other_label", "other_label"), 1862s # using the index name 1862s ("index_name", None, "index_name"), 1862s # has index name, but specifying index_label 1862s ("index_name", "other_label", "other_label"), 1862s # index name is integer 1862s (0, None, "0"), 1862s # index name is None but index label is integer 1862s (None, 0, "0"), 1862s ], 1862s ) 1862s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_index_label_multiindex(conn, request): 1862s conn_name = conn 1862s if "mysql" in conn_name: 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="MySQL can fail using TEXT without length as key", strict=False 1862s ) 1862s ) 1862s elif "adbc" in conn_name: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_index_label", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_to_sql_index_label_multiindex(conn, request): 1862s conn_name = conn 1862s if "mysql" in conn_name: 1862s request.applymarker( 1862s pytest.mark.xfail( 1862s reason="MySQL can fail using TEXT without length as key", strict=False 1862s ) 1862s ) 1862s elif "adbc" in conn_name: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1862s ) 1862s 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_multiindex_roundtrip(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_multiindex_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_multiindex_roundtrip(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_multiindex_roundtrip(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_multiindex_roundtrip", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_multiindex_roundtrip(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s dtype = None 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s dtype = None 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s dtype = None 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s dtype = None 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s dtype = 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s dtype = {'A': , 'B': } 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s dtype = {'A': , 'B': } 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s dtype = {'A': , 'B': } 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_dtype_argument", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s dtype = {'A': , 'B': } 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s @pytest.mark.parametrize( 1862s "dtype", 1862s [ 1862s None, 1862s int, 1862s float, 1862s {"A": int, "B": float}, 1862s ], 1862s ) 1862s def test_api_dtype_argument(conn, request, dtype): 1862s # GH10285 Add dtype argument to read_sql_query 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_integer_col_names(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1862s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_integer_col_names(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_integer_col_names(conn, request): 1862s conn = request.getfixturevalue(conn) 1862s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1862s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1862s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_integer_col_names(conn, request): 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_with_schema(conn, request, test_frame1): 1862s # GH28486 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_with_schema(conn, request, test_frame1): 1862s # GH28486 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_with_schema(conn, request, test_frame1): 1862s # GH28486 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_with_schema(conn, request, test_frame1): 1862s # GH28486 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_dtypes(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1862s 1862s if conn_name == "sqlite_buildin": 1862s dtype = "INTEGER" 1862s else: 1862s from sqlalchemy import Integer 1862s 1862s dtype = Integer 1862s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_dtypes(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_dtypes(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1862s 1862s if conn_name == "sqlite_buildin": 1862s dtype = "INTEGER" 1862s else: 1862s from sqlalchemy import Integer 1862s 1862s dtype = Integer 1862s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_dtypes(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_keys(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1862s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_keys(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_keys(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1862s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1862s with pandasSQL_builder(con=con) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s test_frame1 = index A B C D 1862s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1862s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_get_schema_keys(conn, request, test_frame1): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="'get_schema' not implemented for ADBC drivers", 1862s strict=True, 1862s ) 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_chunksize_read(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_chunksize", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_chunksize_read(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_chunksize_read(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_chunksize", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_chunksize_read(conn, request): 1862s if "adbc" in conn: 1862s request.node.add_marker( 1862s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1862s ) 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_categorical(conn, request): 1862s if conn == "postgresql_adbc_conn": 1862s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1862s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="categorical dtype not implemented for ADBC postgres driver", 1862s strict=True, 1862s ) 1862s ) 1862s # GH8624 1862s # test that categorical gets written correctly as dense column 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_categorical", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_categorical(conn, request): 1862s if conn == "postgresql_adbc_conn": 1862s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1862s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="categorical dtype not implemented for ADBC postgres driver", 1862s strict=True, 1862s ) 1862s ) 1862s # GH8624 1862s # test that categorical gets written correctly as dense column 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_categorical(conn, request): 1862s if conn == "postgresql_adbc_conn": 1862s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1862s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="categorical dtype not implemented for ADBC postgres driver", 1862s strict=True, 1862s ) 1862s ) 1862s # GH8624 1862s # test that categorical gets written correctly as dense column 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_categorical", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_categorical(conn, request): 1862s if conn == "postgresql_adbc_conn": 1862s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1862s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="categorical dtype not implemented for ADBC postgres driver", 1862s strict=True, 1862s ) 1862s ) 1862s # GH8624 1862s # test that categorical gets written correctly as dense column 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_unicode_column_name(conn, request): 1862s # GH 11431 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_unicode", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_unicode_column_name(conn, request): 1862s # GH 11431 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_unicode_column_name(conn, request): 1862s # GH 11431 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_unicode", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_unicode_column_name(conn, request): 1862s # GH 11431 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_escaped_table_name(conn, request): 1862s # GH 13206 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_escaped_table_name(conn, request): 1862s # GH 13206 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_escaped_table_name(conn, request): 1862s # GH 13206 1862s conn_name = conn 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'postgresql_psycopg2_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_escaped_table_name(conn, request): 1862s # GH 13206 1862s conn_name = conn 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1862s with postgresql_psycopg2_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_read_sql_duplicate_columns(conn, request): 1862s # GH#53117 1862s if "adbc" in conn: 1862s pa = pytest.importorskip("pyarrow") 1862s if not ( 1862s Version(pa.__version__) >= Version("16.0") 1862s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1862s ): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="pyarrow->pandas throws ValueError", strict=True 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_table", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s > sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3.13/socket.py:864: in create_connection 1862s raise exceptions[0] 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s address = ('localhost', 3306), timeout = 10, source_address = None 1862s 1862s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1862s source_address=None, *, all_errors=False): 1862s """Connect to *address* and return the socket object. 1862s 1862s Convenience function. Connect to *address* (a 2-tuple ``(host, 1862s port)``) and return the socket object. Passing the optional 1862s *timeout* parameter will set the timeout on the socket instance 1862s before attempting to connect. If no *timeout* is supplied, the 1862s global default timeout setting returned by :func:`getdefaulttimeout` 1862s is used. If *source_address* is set it must be a tuple of (host, port) 1862s for the socket to bind as a source address before making the connection. 1862s A host of '' or port 0 tells the OS to use the default. When a connection 1862s cannot be created, raises the last error if *all_errors* is False, 1862s and an ExceptionGroup of all errors if *all_errors* is True. 1862s """ 1862s 1862s host, port = address 1862s exceptions = [] 1862s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1862s af, socktype, proto, canonname, sa = res 1862s sock = None 1862s try: 1862s sock = socket(af, socktype, proto) 1862s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1862s sock.settimeout(timeout) 1862s if source_address: 1862s sock.bind(source_address) 1862s > sock.connect(sa) 1862s E ConnectionRefusedError: [Errno 111] Connection refused 1862s 1862s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1862s 1862s During handling of the above exception, another exception occurred: 1862s 1862s self = 1862s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1862s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = 'mysql_pymysql_conn' 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_read_sql_duplicate_columns(conn, request): 1862s # GH#53117 1862s if "adbc" in conn: 1862s pa = pytest.importorskip("pyarrow") 1862s if not ( 1862s Version(pa.__version__) >= Version("16.0") 1862s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1862s ): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="pyarrow->pandas throws ValueError", strict=True 1862s ) 1862s ) 1862s > conn = request.getfixturevalue(conn) 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1862s fixturedef = self._get_active_fixturedef(argname) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1862s fixturedef.execute(request=subrequest) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1862s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1862s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1862s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1862s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1862s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1862s return (yield) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1862s result = call_fixture_func(fixturefunc, request, kwargs) 1862s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1862s fixture_result = next(generator) 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1862s with mysql_pymysql_engine.connect() as conn: 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1862s self.connect() 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s self = , sock = None 1862s 1862s def connect(self, sock=None): 1862s self._closed = False 1862s try: 1862s if sock is None: 1862s if self.unix_socket: 1862s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1862s sock.settimeout(self.connect_timeout) 1862s sock.connect(self.unix_socket) 1862s self.host_info = "Localhost via UNIX socket" 1862s self._secure = True 1862s if DEBUG: 1862s print("connected using unix_socket") 1862s else: 1862s kwargs = {} 1862s if self.bind_address is not None: 1862s kwargs["source_address"] = (self.bind_address, 0) 1862s while True: 1862s try: 1862s sock = socket.create_connection( 1862s (self.host, self.port), self.connect_timeout, **kwargs 1862s ) 1862s break 1862s except OSError as e: 1862s if e.errno == errno.EINTR: 1862s continue 1862s raise 1862s self.host_info = "socket %s:%d" % (self.host, self.port) 1862s if DEBUG: 1862s print("connected using socket") 1862s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1862s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1862s sock.settimeout(None) 1862s 1862s self._sock = sock 1862s self._rfile = sock.makefile("rb") 1862s self._next_seq_id = 0 1862s 1862s self._get_server_information() 1862s self._request_authentication() 1862s 1862s # Send "SET NAMES" query on init for: 1862s # - Ensure charaset (and collation) is set to the server. 1862s # - collation_id in handshake packet may be ignored. 1862s # - If collation is not specified, we don't know what is server's 1862s # default collation for the charset. For example, default collation 1862s # of utf8mb4 is: 1862s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1862s # - MySQL 8.0: utf8mb4_0900_ai_ci 1862s # 1862s # Reference: 1862s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1862s # - https://github.com/wagtail/wagtail/issues/9477 1862s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1862s self.set_character_set(self.charset, self.collation) 1862s 1862s if self.sql_mode is not None: 1862s c = self.cursor() 1862s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1862s c.close() 1862s 1862s if self.init_command is not None: 1862s c = self.cursor() 1862s c.execute(self.init_command) 1862s c.close() 1862s 1862s if self.autocommit_mode is not None: 1862s self.autocommit(self.autocommit_mode) 1862s except BaseException as e: 1862s self._rfile = None 1862s if sock is not None: 1862s try: 1862s sock.close() 1862s except: # noqa 1862s pass 1862s 1862s if isinstance(e, (OSError, IOError)): 1862s exc = err.OperationalError( 1862s CR.CR_CONN_HOST_ERROR, 1862s f"Can't connect to MySQL server on {self.host!r} ({e})", 1862s ) 1862s # Keep original exception and traceback to investigate error. 1862s exc.original_exception = e 1862s exc.traceback = traceback.format_exc() 1862s if DEBUG: 1862s print(exc.traceback) 1862s > raise exc 1862s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1862s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s 1862s The above exception was the direct cause of the following exception: 1862s 1862s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s request = > 1862s 1862s @pytest.mark.parametrize("conn", all_connectable) 1862s def test_api_read_sql_duplicate_columns(conn, request): 1862s # GH#53117 1862s if "adbc" in conn: 1862s pa = pytest.importorskip("pyarrow") 1862s if not ( 1862s Version(pa.__version__) >= Version("16.0") 1862s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1862s ): 1862s request.node.add_marker( 1862s pytest.mark.xfail( 1862s reason="pyarrow->pandas throws ValueError", strict=True 1862s ) 1862s ) 1862s conn = request.getfixturevalue(conn) 1862s > if sql.has_table("test_table", conn): 1862s 1862s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1862s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1862s return SQLDatabase(con, schema, need_transaction) 1862s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1862s con = self.exit_stack.enter_context(con.connect()) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1862s return self._connection_cls(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1862s Connection._handle_dbapi_exception_noconnection( 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1862s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1862s self._dbapi_connection = engine.raw_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1862s raise exc_value.with_traceback(exc_tb) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1862s self.dbapi_connection = connection = pool._invoke_creator(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1862s return dialect.connect(*cargs, **cparams) 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1862s return self.loaded_dbapi.connect(*cargs, **cparams) 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s 1862s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1862s connection_factory = None, cursor_factory = None 1862s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1862s kwasync = {} 1862s 1862s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1862s """ 1862s Create a new database connection. 1862s 1862s The connection parameters can be specified as a string: 1862s 1862s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1862s 1862s or using a set of keyword arguments: 1862s 1862s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1862s 1862s Or as a mix of both. The basic connection parameters are: 1862s 1862s - *dbname*: the database name 1862s - *database*: the database name (only as keyword argument) 1862s - *user*: user name used to authenticate 1862s - *password*: password used to authenticate 1862s - *host*: database host address (defaults to UNIX socket if not provided) 1862s - *port*: connection port number (defaults to 5432 if not provided) 1862s 1862s Using the *connection_factory* parameter a different class or connections 1862s factory can be specified. It should be a callable object taking a dsn 1862s argument. 1862s 1862s Using the *cursor_factory* parameter, a new default cursor factory will be 1862s used by cursor(). 1862s 1862s Using *async*=True an asynchronous connection will be created. *async_* is 1862s a valid alias (for Python versions where ``async`` is a keyword). 1862s 1862s Any other keyword parameter will be passed to the underlying client 1862s library: the list of supported parameters depends on the library version. 1862s 1862s """ 1862s kwasync = {} 1862s if 'async' in kwargs: 1862s kwasync['async'] = kwargs.pop('async') 1862s if 'async_' in kwargs: 1862s kwasync['async_'] = kwargs.pop('async_') 1862s 1862s dsn = _ext.make_dsn(dsn, **kwargs) 1862s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1862s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1862s E Is the server running on that host and accepting TCP/IP connections? 1862s E 1862s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1862s 1862s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1862s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 1862s self = 1862s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1862s connection = None, _has_events = None, _allow_revalidate = True 1862s _allow_autobegin = True 1862s 1862s def __init__( 1862s self, 1862s engine: Engine, 1862s connection: Optional[PoolProxiedConnection] = None, 1862s _has_events: Optional[bool] = None, 1862s _allow_revalidate: bool = True, 1862s _allow_autobegin: bool = True, 1862s ): 1862s """Construct a new Connection.""" 1862s self.engine = engine 1862s self.dialect = dialect = engine.dialect 1862s 1862s if connection is None: 1862s try: 1862s > self._dbapi_connection = engine.raw_connection() 1862s 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1862s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1862s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1862s return self.pool.connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1862s return _ConnectionFairy._checkout(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1862s fairy = _ConnectionRecord.checkout(pool) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1862s rec = pool._do_get() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1862s return self._create_connection() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1862s return _ConnectionRecord(self) 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1862s self.__connect() 1862s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1862s with util.safe_reraise(): 1862s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_api_read_sql_duplicate_columns(conn, request): 1863s # GH#53117 1863s if "adbc" in conn: 1863s pa = pytest.importorskip("pyarrow") 1863s if not ( 1863s Version(pa.__version__) >= Version("16.0") 1863s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1863s ): 1863s request.node.add_marker( 1863s pytest.mark.xfail( 1863s reason="pyarrow->pandas throws ValueError", strict=True 1863s ) 1863s ) 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_columns(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s > sql.to_sql(test_frame1, "test_frame", conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_columns(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_columns(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s > sql.to_sql(test_frame1, "test_frame", conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_columns(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_index_col(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s > sql.to_sql(test_frame1, "test_frame", conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_index_col(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_index_col(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s > sql.to_sql(test_frame1, "test_frame", conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_read_table_index_col(conn, request, test_frame1): 1863s # test columns argument in read_table 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_read_sql_delegate(conn, request): 1863s if conn == "sqlite_buildin_iris": 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="sqlite_buildin connection does not implement read_sql_table" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_read_sql_delegate(conn, request): 1863s if conn == "sqlite_buildin_iris": 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="sqlite_buildin connection does not implement read_sql_table" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_read_sql_delegate(conn, request): 1863s if conn == "sqlite_buildin_iris": 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="sqlite_buildin connection does not implement read_sql_table" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_read_sql_delegate(conn, request): 1863s if conn == "sqlite_buildin_iris": 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="sqlite_buildin connection does not implement read_sql_table" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s # see gh-7815 1863s with tm.assert_produces_warning( 1863s UserWarning, 1863s match=( 1863s r"The provided table name 'TABLE1' is not found exactly as such in " 1863s r"the database after writing the table, possibly due to case " 1863s r"sensitivity issues. Consider using lower case table names." 1863s ), 1863s ): 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s # see gh-7815 1863s > with tm.assert_produces_warning( 1863s UserWarning, 1863s match=( 1863s r"The provided table name 'TABLE1' is not found exactly as such in " 1863s r"the database after writing the table, possibly due to case " 1863s r"sensitivity issues. Consider using lower case table names." 1863s ), 1863s ): 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1863s self.gen.throw(value) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s def _assert_caught_expected_warning( 1863s *, 1863s caught_warnings: Sequence[warnings.WarningMessage], 1863s expected_warning: type[Warning], 1863s match: str | None, 1863s check_stacklevel: bool, 1863s ) -> None: 1863s """Assert that there was the expected warning among the caught warnings.""" 1863s saw_warning = False 1863s matched_message = False 1863s unmatched_messages = [] 1863s 1863s for actual_warning in caught_warnings: 1863s if issubclass(actual_warning.category, expected_warning): 1863s saw_warning = True 1863s 1863s if check_stacklevel: 1863s _assert_raised_with_correct_stacklevel(actual_warning) 1863s 1863s if match is not None: 1863s if re.search(match, str(actual_warning.message)): 1863s matched_message = True 1863s else: 1863s unmatched_messages.append(actual_warning.message) 1863s 1863s if not saw_warning: 1863s > raise AssertionError( 1863s f"Did not see expected warning of class " 1863s f"{repr(expected_warning.__name__)}" 1863s ) 1863s E AssertionError: Did not see expected warning of class 'UserWarning' 1863s 1863s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1863s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s # see gh-7815 1863s with tm.assert_produces_warning( 1863s UserWarning, 1863s match=( 1863s r"The provided table name 'TABLE1' is not found exactly as such in " 1863s r"the database after writing the table, possibly due to case " 1863s r"sensitivity issues. Consider using lower case table names." 1863s ), 1863s ): 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s # see gh-7815 1863s > with tm.assert_produces_warning( 1863s UserWarning, 1863s match=( 1863s r"The provided table name 'TABLE1' is not found exactly as such in " 1863s r"the database after writing the table, possibly due to case " 1863s r"sensitivity issues. Consider using lower case table names." 1863s ), 1863s ): 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1863s self.gen.throw(value) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s def _assert_caught_expected_warning( 1863s *, 1863s caught_warnings: Sequence[warnings.WarningMessage], 1863s expected_warning: type[Warning], 1863s match: str | None, 1863s check_stacklevel: bool, 1863s ) -> None: 1863s """Assert that there was the expected warning among the caught warnings.""" 1863s saw_warning = False 1863s matched_message = False 1863s unmatched_messages = [] 1863s 1863s for actual_warning in caught_warnings: 1863s if issubclass(actual_warning.category, expected_warning): 1863s saw_warning = True 1863s 1863s if check_stacklevel: 1863s _assert_raised_with_correct_stacklevel(actual_warning) 1863s 1863s if match is not None: 1863s if re.search(match, str(actual_warning.message)): 1863s matched_message = True 1863s else: 1863s unmatched_messages.append(actual_warning.message) 1863s 1863s if not saw_warning: 1863s > raise AssertionError( 1863s f"Did not see expected warning of class " 1863s f"{repr(expected_warning.__name__)}" 1863s ) 1863s E AssertionError: Did not see expected warning of class 'UserWarning' 1863s 1863s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1863s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1863s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_sqlalchemy_type_mapping(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s from sqlalchemy import TIMESTAMP 1863s 1863s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1863s df = DataFrame( 1863s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1863s ) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_sqlalchemy_type_mapping(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_sqlalchemy_type_mapping(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s from sqlalchemy import TIMESTAMP 1863s 1863s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1863s df = DataFrame( 1863s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1863s ) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_sqlalchemy_type_mapping(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'Int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'Int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'Int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'Int8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'uint8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'uint8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'uint8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'uint8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'UInt8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'UInt8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'UInt8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'UInt8', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'Int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'Int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'Int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'Int16', expected = 'SMALLINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'uint16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'uint16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'uint16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'uint16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'UInt16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'UInt16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'UInt16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'UInt16', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'Int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'Int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'Int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'Int32', expected = 'INTEGER' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'uint32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'uint32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'uint32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'uint32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'UInt32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'UInt32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'UInt32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'UInt32', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'Int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'Int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'Int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'Int64', expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = , expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = , expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = , expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = , expected = 'BIGINT' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "integer, expected", 1863s [ 1863s ("int8", "SMALLINT"), 1863s ("Int8", "SMALLINT"), 1863s ("uint8", "SMALLINT"), 1863s ("UInt8", "SMALLINT"), 1863s ("int16", "SMALLINT"), 1863s ("Int16", "SMALLINT"), 1863s ("uint16", "INTEGER"), 1863s ("UInt16", "INTEGER"), 1863s ("int32", "INTEGER"), 1863s ("Int32", "INTEGER"), 1863s ("uint32", "BIGINT"), 1863s ("UInt32", "BIGINT"), 1863s ("int64", "BIGINT"), 1863s ("Int64", "BIGINT"), 1863s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1863s ], 1863s ) 1863s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'uint64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s conn = request.getfixturevalue(conn) 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'uint64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'uint64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s conn = request.getfixturevalue(conn) 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'uint64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s integer = 'UInt64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s conn = request.getfixturevalue(conn) 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s integer = 'UInt64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s integer = 'UInt64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s conn = request.getfixturevalue(conn) 1863s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1863s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1863s > with sql.SQLDatabase(conn) as db: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s integer = 'UInt64' 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1863s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_database_uri_string(conn, request, test_frame1): 1863s td.versioned_importorskip("sqlalchemy") 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_database_uri_string(conn, request, test_frame1): 1863s td.versioned_importorskip("sqlalchemy") 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @td.skip_if_installed("pg8000") 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1863s td.versioned_importorskip("sqlalchemy") 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @td.skip_if_installed("pg8000") 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1863s td.versioned_importorskip("sqlalchemy") 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_text_obj(conn, request): 1863s # WIP : GH10846 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_text_obj(conn, request): 1863s # WIP : GH10846 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_text_obj(conn, request): 1863s # WIP : GH10846 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_text_obj(conn, request): 1863s # WIP : GH10846 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_select_obj(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_select_obj(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_select_obj(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_query_by_select_obj(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_column_with_percentage(conn, request): 1863s # GH 37157 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1863s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_column_with_percentage(conn, request): 1863s # GH 37157 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_column_with_percentage(conn, request): 1863s # GH 37157 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1863s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_column_with_percentage(conn, request): 1863s # GH 37157 1863s conn_name = conn 1863s if conn_name == "sqlite_buildin": 1863s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_create_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import inspect 1863s 1863s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1863s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_create_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_create_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import inspect 1863s 1863s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1863s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_create_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_drop_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import inspect 1863s 1863s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1863s > with sql.SQLDatabase(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_drop_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_drop_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import inspect 1863s 1863s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1863s > with sql.SQLDatabase(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_drop_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_roundtrip(conn, request, test_frame1): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s > pandasSQL = pandasSQL_builder(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_roundtrip(conn, request, test_frame1): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_roundtrip(conn, request, test_frame1): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s > pandasSQL = pandasSQL_builder(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_roundtrip(conn, request, test_frame1): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_execute_sql(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_execute_sql(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_execute_sql(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable_iris) 1863s def test_execute_sql(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table_columns(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table_columns(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table_columns(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_sqlalchemy_read_table_columns(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_read_table_absent_raises(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_read_table_absent_raises(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1863s create_and_load_iris(mysql_pymysql_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_read_table_absent_raises(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_iris' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1863s def test_read_table_absent_raises(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1863s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1863s with conn.begin() as con: 1863s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1863s return next(self.gen) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1863s with self.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_sqlalchemy_default_type_conversion(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "mysql" in conn_name or "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_sqlalchemy_default_type_conversion(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "mysql" in conn_name or "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_bigint(conn, request): 1863s # int64 should be converted to BigInteger, GH7433 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame(data={"i64": [2**62]}) 1863s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_bigint(conn, request): 1863s # int64 should be converted to BigInteger, GH7433 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_bigint(conn, request): 1863s # int64 should be converted to BigInteger, GH7433 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame(data={"i64": [2**62]}) 1863s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_bigint(conn, request): 1863s # int64 should be converted to BigInteger, GH7433 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_default_date_load(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="sqlite does not read date properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1863s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_default_date_load(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="sqlite does not read date properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1863s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_default_date_load(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="sqlite does not read date properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_default_date_load(conn, request): 1863s conn_name = conn 1863s if conn_name == "sqlite_str": 1863s pytest.skip("types tables not created in sqlite_str fixture") 1863s elif "sqlite" in conn_name: 1863s request.applymarker( 1863s pytest.mark.xfail(reason="sqlite does not read date properly") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s parse_dates = None 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1863s def test_datetime_with_timezone_query(conn, request, parse_dates): 1863s # edge case that converts postgresql datetime with time zone types 1863s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1863s # but should be more natural, so coerce to datetime64[ns] for now 1863s conn = request.getfixturevalue(conn) 1863s > expected = create_and_load_postgres_datetz(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s parse_dates = None 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1863s def test_datetime_with_timezone_query(conn, request, parse_dates): 1863s # edge case that converts postgresql datetime with time zone types 1863s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1863s # but should be more natural, so coerce to datetime64[ns] for now 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s parse_dates = ['DateColWithTz'] 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1863s def test_datetime_with_timezone_query(conn, request, parse_dates): 1863s # edge case that converts postgresql datetime with time zone types 1863s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1863s # but should be more natural, so coerce to datetime64[ns] for now 1863s conn = request.getfixturevalue(conn) 1863s > expected = create_and_load_postgres_datetz(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s parse_dates = ['DateColWithTz'] 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1863s def test_datetime_with_timezone_query(conn, request, parse_dates): 1863s # edge case that converts postgresql datetime with time zone types 1863s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1863s # but should be more natural, so coerce to datetime64[ns] for now 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s def test_datetime_with_timezone_query_chunksize(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s > expected = create_and_load_postgres_datetz(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s def test_datetime_with_timezone_query_chunksize(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s def test_datetime_with_timezone_table(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s > expected = create_and_load_postgres_datetz(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", postgresql_connectable) 1863s def test_datetime_with_timezone_table(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_with_timezone_roundtrip(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s # GH 9086 1863s # Write datetimetz data to a db and read it back 1863s # For dbs that support timestamps with timezones, should get back UTC 1863s # otherwise naive data should be returned 1863s expected = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1863s ) 1863s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_with_timezone_roundtrip(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_with_timezone_roundtrip(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s # GH 9086 1863s # Write datetimetz data to a db and read it back 1863s # For dbs that support timestamps with timezones, should get back UTC 1863s # otherwise naive data should be returned 1863s expected = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1863s ) 1863s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_with_timezone_roundtrip(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_out_of_bounds_datetime(conn, request): 1863s # GH 26761 1863s conn = request.getfixturevalue(conn) 1863s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1863s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_out_of_bounds_datetime(conn, request): 1863s # GH 26761 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_out_of_bounds_datetime(conn, request): 1863s # GH 26761 1863s conn = request.getfixturevalue(conn) 1863s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1863s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_out_of_bounds_datetime(conn, request): 1863s # GH 26761 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_naive_datetimeindex_roundtrip(conn, request): 1863s # GH 23510 1863s # Ensure that a naive DatetimeIndex isn't converted to UTC 1863s conn = request.getfixturevalue(conn) 1863s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1863s expected = DataFrame({"nums": range(5)}, index=dates) 1863s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_naive_datetimeindex_roundtrip(conn, request): 1863s # GH 23510 1863s # Ensure that a naive DatetimeIndex isn't converted to UTC 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_naive_datetimeindex_roundtrip(conn, request): 1863s # GH 23510 1863s # Ensure that a naive DatetimeIndex isn't converted to UTC 1863s conn = request.getfixturevalue(conn) 1863s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1863s expected = DataFrame({"nums": range(5)}, index=dates) 1863s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_naive_datetimeindex_roundtrip(conn, request): 1863s # GH 23510 1863s # Ensure that a naive DatetimeIndex isn't converted to UTC 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_engine_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_date_parsing(conn, request): 1863s # No Parsing 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1863s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_date_parsing(conn, request): 1863s # No Parsing 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1863s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_engine_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_date_parsing(conn, request): 1863s # No Parsing 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn_types' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1863s def test_date_parsing(conn, request): 1863s # No Parsing 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1863s fixturedef = request._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1863s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1863s with conn.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1863s ) 1863s > assert df.to_sql(name="test_datetime", con=conn) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1863s ) 1863s > assert df.to_sql(name="test_datetime", con=conn) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_NaT(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1863s ) 1863s df.loc[1, "A"] = np.nan 1863s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_NaT(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_NaT(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame( 1863s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1863s ) 1863s df.loc[1, "A"] = np.nan 1863s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_NaT(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_date(conn, request): 1863s # test support for datetime.date 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1863s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_date(conn, request): 1863s # test support for datetime.date 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_date(conn, request): 1863s # test support for datetime.date 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1863s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_date(conn, request): 1863s # test support for datetime.date 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s sqlite_buildin = 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_time(conn, request, sqlite_buildin): 1863s # test support for datetime.time 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1863s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s sqlite_buildin = 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_time(conn, request, sqlite_buildin): 1863s # test support for datetime.time 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s sqlite_buildin = 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_time(conn, request, sqlite_buildin): 1863s # test support for datetime.time 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1863s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s sqlite_buildin = 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_datetime_time(conn, request, sqlite_buildin): 1863s # test support for datetime.time 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_mixed_dtype_insert(conn, request): 1863s # see GH6509 1863s conn = request.getfixturevalue(conn) 1863s s1 = Series(2**25 + 1, dtype=np.int32) 1863s s2 = Series(0.0, dtype=np.float32) 1863s df = DataFrame({"s1": s1, "s2": s2}) 1863s 1863s # write and read again 1863s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_mixed_dtype_insert(conn, request): 1863s # see GH6509 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_mixed_dtype_insert(conn, request): 1863s # see GH6509 1863s conn = request.getfixturevalue(conn) 1863s s1 = Series(2**25 + 1, dtype=np.int32) 1863s s2 = Series(0.0, dtype=np.float32) 1863s df = DataFrame({"s1": s1, "s2": s2}) 1863s 1863s # write and read again 1863s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_mixed_dtype_insert(conn, request): 1863s # see GH6509 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_numeric(conn, request): 1863s # NaNs in numeric float column 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_numeric(conn, request): 1863s # NaNs in numeric float column 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_numeric(conn, request): 1863s # NaNs in numeric float column 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_numeric(conn, request): 1863s # NaNs in numeric float column 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_fullcolumn(conn, request): 1863s # full NaN column (numeric float column) 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_fullcolumn(conn, request): 1863s # full NaN column (numeric float column) 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_fullcolumn(conn, request): 1863s # full NaN column (numeric float column) 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_fullcolumn(conn, request): 1863s # full NaN column (numeric float column) 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_string(conn, request): 1863s # NaNs in string column 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_string(conn, request): 1863s # NaNs in string column 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_string(conn, request): 1863s # NaNs in string column 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1863s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_nan_string(conn, request): 1863s # NaNs in string column 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_save_index(conn, request): 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail( 1863s reason="ADBC implementation does not create index", strict=True 1863s ) 1863s ) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame.from_records( 1863s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1863s ) 1863s 1863s tbl_name = "test_to_sql_saves_index" 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_save_index(conn, request): 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail( 1863s reason="ADBC implementation does not create index", strict=True 1863s ) 1863s ) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_save_index(conn, request): 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail( 1863s reason="ADBC implementation does not create index", strict=True 1863s ) 1863s ) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s df = DataFrame.from_records( 1863s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1863s ) 1863s 1863s tbl_name = "test_to_sql_saves_index" 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_save_index(conn, request): 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail( 1863s reason="ADBC implementation does not create index", strict=True 1863s ) 1863s ) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transactions(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1863s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1863s from sqlalchemy import text 1863s 1863s stmt = text(stmt) 1863s 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transactions(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transactions(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1863s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1863s from sqlalchemy import text 1863s 1863s stmt = text(stmt) 1863s 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transactions(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transaction_rollback(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transaction_rollback(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transaction_rollback(conn, request): 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_transaction_rollback(conn, request): 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame3 = index A B 1863s 0 2000-01-03 00:00:00 2147483647 -1.987670 1863s 1 2000-01-04 00:00:00 -29 -0.041232 1863s 2 2000-01-05 00:00:00 20000 0.731168 1863s 3 2000-01-06 00:00:00 -290867 1.567621 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_get_schema_create_table(conn, request, test_frame3): 1863s # Use a dataframe without a bool column, since MySQL converts bool to 1863s # TINYINT (which read_sql_table returns as an int and causes a dtype 1863s # mismatch) 1863s if conn == "sqlite_str": 1863s request.applymarker( 1863s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1863s ) 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import text 1863s from sqlalchemy.engine import Engine 1863s 1863s tbl = "test_get_schema_create_table" 1863s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1863s with pandasSQL_builder(con=con) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame3 = index A B 1863s 0 2000-01-03 00:00:00 2147483647 -1.987670 1863s 1 2000-01-04 00:00:00 -29 -0.041232 1863s 2 2000-01-05 00:00:00 20000 0.731168 1863s 3 2000-01-06 00:00:00 -290867 1.567621 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_get_schema_create_table(conn, request, test_frame3): 1863s # Use a dataframe without a bool column, since MySQL converts bool to 1863s # TINYINT (which read_sql_table returns as an int and causes a dtype 1863s # mismatch) 1863s if conn == "sqlite_str": 1863s request.applymarker( 1863s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame3 = index A B 1863s 0 2000-01-03 00:00:00 2147483647 -1.987670 1863s 1 2000-01-04 00:00:00 -29 -0.041232 1863s 2 2000-01-05 00:00:00 20000 0.731168 1863s 3 2000-01-06 00:00:00 -290867 1.567621 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_get_schema_create_table(conn, request, test_frame3): 1863s # Use a dataframe without a bool column, since MySQL converts bool to 1863s # TINYINT (which read_sql_table returns as an int and causes a dtype 1863s # mismatch) 1863s if conn == "sqlite_str": 1863s request.applymarker( 1863s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1863s ) 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import text 1863s from sqlalchemy.engine import Engine 1863s 1863s tbl = "test_get_schema_create_table" 1863s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1863s with pandasSQL_builder(con=con) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame3 = index A B 1863s 0 2000-01-03 00:00:00 2147483647 -1.987670 1863s 1 2000-01-04 00:00:00 -29 -0.041232 1863s 2 2000-01-05 00:00:00 20000 0.731168 1863s 3 2000-01-06 00:00:00 -290867 1.567621 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_get_schema_create_table(conn, request, test_frame3): 1863s # Use a dataframe without a bool column, since MySQL converts bool to 1863s # TINYINT (which read_sql_table returns as an int and causes a dtype 1863s # mismatch) 1863s if conn == "sqlite_str": 1863s request.applymarker( 1863s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s TEXT, 1863s String, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s cols = ["A", "B"] 1863s data = [(0.8, True), (0.9, None)] 1863s df = DataFrame(data, columns=cols) 1863s > assert df.to_sql(name="dtype_test", con=conn) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s TEXT, 1863s String, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s cols = ["A", "B"] 1863s data = [(0.8, True), (0.9, None)] 1863s df = DataFrame(data, columns=cols) 1863s > assert df.to_sql(name="dtype_test", con=conn) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_notna_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s Boolean, 1863s DateTime, 1863s Float, 1863s Integer, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s cols = { 1863s "Bool": Series([True, None]), 1863s "Date": Series([datetime(2012, 5, 1), None]), 1863s "Int": Series([1, None], dtype="object"), 1863s "Float": Series([1.1, None]), 1863s } 1863s df = DataFrame(cols) 1863s 1863s tbl = "notna_dtype_test" 1863s > assert df.to_sql(name=tbl, con=conn) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_notna_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_notna_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s Boolean, 1863s DateTime, 1863s Float, 1863s Integer, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s cols = { 1863s "Bool": Series([True, None]), 1863s "Date": Series([datetime(2012, 5, 1), None]), 1863s "Int": Series([1, None], dtype="object"), 1863s "Float": Series([1.1, None]), 1863s } 1863s df = DataFrame(cols) 1863s 1863s tbl = "notna_dtype_test" 1863s > assert df.to_sql(name=tbl, con=conn) == 2 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_notna_dtype(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_double_precision[mysql_pymysql_engine] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_double_precision(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s BigInteger, 1863s Float, 1863s Integer, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s V = 1.23456789101112131415 1863s 1863s df = DataFrame( 1863s { 1863s "f32": Series([V], dtype="float32"), 1863s "f64": Series([V], dtype="float64"), 1863s "f64_as_f32": Series([V], dtype="float64"), 1863s "i32": Series([5], dtype="int32"), 1863s "i64": Series([5], dtype="int64"), 1863s } 1863s ) 1863s 1863s assert ( 1863s > df.to_sql( 1863s name="test_dtypes", 1863s con=conn, 1863s index=False, 1863s if_exists="replace", 1863s dtype={"f64_as_f32": Float(precision=23)}, 1863s ) 1863s == 1 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_double_precision(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_double_precision(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s BigInteger, 1863s Float, 1863s Integer, 1863s ) 1863s from sqlalchemy.schema import MetaData 1863s 1863s V = 1.23456789101112131415 1863s 1863s df = DataFrame( 1863s { 1863s "f32": Series([V], dtype="float32"), 1863s "f64": Series([V], dtype="float64"), 1863s "f64_as_f32": Series([V], dtype="float64"), 1863s "i32": Series([5], dtype="int32"), 1863s "i64": Series([5], dtype="int64"), 1863s } 1863s ) 1863s 1863s assert ( 1863s > df.to_sql( 1863s name="test_dtypes", 1863s con=conn, 1863s index=False, 1863s if_exists="replace", 1863s dtype={"f64_as_f32": Float(precision=23)}, 1863s ) 1863s == 1 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_double_precision(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("sqlite_str has no inspection system") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_connectable_issue_example(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s 1863s # This tests the example raised in issue 1863s # https://github.com/pandas-dev/pandas/issues/10104 1863s from sqlalchemy.engine import Engine 1863s 1863s def test_select(connection): 1863s query = "SELECT test_foo_data FROM test_foo_data" 1863s return sql.read_sql_query(query, con=connection) 1863s 1863s def test_append(connection, data): 1863s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1863s 1863s def test_connectable(conn): 1863s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1863s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1863s foo_data = test_select(conn) 1863s test_append(conn, foo_data) 1863s 1863s def main(connectable): 1863s if isinstance(connectable, Engine): 1863s with connectable.connect() as conn: 1863s with conn.begin(): 1863s test_connectable(conn) 1863s else: 1863s test_connectable(connectable) 1863s 1863s assert ( 1863s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1863s == 3 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_connectable_issue_example(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_connectable_issue_example(conn, request): 1863s conn = request.getfixturevalue(conn) 1863s 1863s # This tests the example raised in issue 1863s # https://github.com/pandas-dev/pandas/issues/10104 1863s from sqlalchemy.engine import Engine 1863s 1863s def test_select(connection): 1863s query = "SELECT test_foo_data FROM test_foo_data" 1863s return sql.read_sql_query(query, con=connection) 1863s 1863s def test_append(connection, data): 1863s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1863s 1863s def test_connectable(conn): 1863s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1863s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1863s foo_data = test_select(conn) 1863s test_append(conn, foo_data) 1863s 1863s def main(connectable): 1863s if isinstance(connectable, Engine): 1863s with connectable.connect() as conn: 1863s with conn.begin(): 1863s test_connectable(conn) 1863s else: 1863s test_connectable(connectable) 1863s 1863s assert ( 1863s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1863s == 3 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_connectable_issue_example(conn, request): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s input = {'foo': [inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s > df.to_sql(name="foobar", con=conn, index=False) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s input = {'foo': [inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s input = {'foo': [inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s df.to_sql(name="foobar", con=conn, index=False) 1863s else: 1863s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s input = {'foo': [inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s input = {'foo': [-inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s > df.to_sql(name="foobar", con=conn, index=False) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s input = {'foo': [-inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s input = {'foo': [-inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s df.to_sql(name="foobar", con=conn, index=False) 1863s else: 1863s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s input = {'foo': [-inf]} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s input = {'foo': [-inf], 'infe0': ['bar']} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s > df.to_sql(name="foobar", con=conn, index=False) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s input = {'foo': [-inf], 'infe0': ['bar']} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s input = {'foo': [-inf], 'infe0': ['bar']} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s 1863s if "mysql" in conn_name: 1863s # GH 36465 1863s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1863s # for pymysql version >= 0.10 1863s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1863s pymysql = td.versioned_importorskip("pymysql") 1863s 1863s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1863s mark = pytest.mark.xfail(reason="GH 36465") 1863s request.applymarker(mark) 1863s 1863s msg = "inf cannot be used with MySQL" 1863s with pytest.raises(ValueError, match=msg): 1863s df.to_sql(name="foobar", con=conn, index=False) 1863s else: 1863s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s input = {'foo': [-inf], 'infe0': ['bar']} 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s @pytest.mark.parametrize( 1863s "input", 1863s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1863s ) 1863s def test_to_sql_with_negative_npinf(conn, request, input): 1863s # GH 34431 1863s 1863s df = DataFrame(input) 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_temporary_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("test does not work with str connection") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s Column, 1863s Integer, 1863s Unicode, 1863s select, 1863s ) 1863s from sqlalchemy.orm import ( 1863s Session, 1863s declarative_base, 1863s ) 1863s 1863s test_data = "Hello, World!" 1863s expected = DataFrame({"spam": [test_data]}) 1863s Base = declarative_base() 1863s 1863s class Temporary(Base): 1863s __tablename__ = "temp_test" 1863s __table_args__ = {"prefixes": ["TEMPORARY"]} 1863s id = Column(Integer, primary_key=True) 1863s spam = Column(Unicode(30), nullable=False) 1863s 1863s with Session(conn) as session: 1863s with session.begin(): 1863s > conn = session.connection() 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1863s return self._connection_for_bind( 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1863s return trans._connection_for_bind(engine, execution_options) 1863s :2: in _connection_for_bind 1863s ??? 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1863s ret_value = fn(self, *arg, **kw) 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1863s conn = bind.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_temporary_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("test does not work with str connection") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_temporary_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("test does not work with str connection") 1863s 1863s conn = request.getfixturevalue(conn) 1863s 1863s from sqlalchemy import ( 1863s Column, 1863s Integer, 1863s Unicode, 1863s select, 1863s ) 1863s from sqlalchemy.orm import ( 1863s Session, 1863s declarative_base, 1863s ) 1863s 1863s test_data = "Hello, World!" 1863s expected = DataFrame({"spam": [test_data]}) 1863s Base = declarative_base() 1863s 1863s class Temporary(Base): 1863s __tablename__ = "temp_test" 1863s __table_args__ = {"prefixes": ["TEMPORARY"]} 1863s id = Column(Integer, primary_key=True) 1863s spam = Column(Unicode(30), nullable=False) 1863s 1863s with Session(conn) as session: 1863s with session.begin(): 1863s > conn = session.connection() 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1863s return self._connection_for_bind( 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1863s return trans._connection_for_bind(engine, execution_options) 1863s :2: in _connection_for_bind 1863s ??? 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1863s ret_value = fn(self, *arg, **kw) 1863s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1863s conn = bind.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_temporary_table(conn, request): 1863s if conn == "sqlite_str": 1863s pytest.skip("test does not work with str connection") 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_invalid_engine(conn, request, test_frame1): 1863s if conn == "sqlite_buildin" or "adbc" in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1863s ) 1863s ) 1863s 1863s conn = request.getfixturevalue(conn) 1863s msg = "engine must be one of 'auto', 'sqlalchemy'" 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_invalid_engine(conn, request, test_frame1): 1863s if conn == "sqlite_buildin" or "adbc" in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_invalid_engine(conn, request, test_frame1): 1863s if conn == "sqlite_buildin" or "adbc" in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1863s ) 1863s ) 1863s 1863s conn = request.getfixturevalue(conn) 1863s msg = "engine must be one of 'auto', 'sqlalchemy'" 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_invalid_engine(conn, request, test_frame1): 1863s if conn == "sqlite_buildin" or "adbc" in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1863s ) 1863s ) 1863s 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1863s """`to_sql` with the `engine` param""" 1863s # mostly copied from this class's `_to_sql()` method 1863s conn = request.getfixturevalue(conn) 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1863s """`to_sql` with the `engine` param""" 1863s # mostly copied from this class's `_to_sql()` method 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1863s """`to_sql` with the `engine` param""" 1863s # mostly copied from this class's `_to_sql()` method 1863s conn = request.getfixturevalue(conn) 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1863s """`to_sql` with the `engine` param""" 1863s # mostly copied from this class's `_to_sql()` method 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_options_sqlalchemy(conn, request, test_frame1): 1863s # use the set option 1863s conn = request.getfixturevalue(conn) 1863s with pd.option_context("io.sql.engine", "sqlalchemy"): 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_options_sqlalchemy(conn, request, test_frame1): 1863s # use the set option 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_options_sqlalchemy(conn, request, test_frame1): 1863s # use the set option 1863s conn = request.getfixturevalue(conn) 1863s with pd.option_context("io.sql.engine", "sqlalchemy"): 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1863s def test_options_sqlalchemy(conn, request, test_frame1): 1863s # use the set option 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_options_auto(conn, request, test_frame1): 1863s # use the set option 1863s conn = request.getfixturevalue(conn) 1863s with pd.option_context("io.sql.engine", "auto"): 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_options_auto(conn, request, test_frame1): 1863s # use the set option 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_options_auto(conn, request, test_frame1): 1863s # use the set option 1863s conn = request.getfixturevalue(conn) 1863s with pd.option_context("io.sql.engine", "auto"): 1863s > with pandasSQL_builder(conn) as pandasSQL: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s test_frame1 = index A B C D 1863s 0 2000-01-03 00:00:00 0.980269 3.685731 -0.364217 -1...0-01-05 00:00:00 0.498581 0.731168 -0.537677 1.346270 1863s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_options_auto(conn, request, test_frame1): 1863s # use the set option 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77100> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77100> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77100> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77100> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql_query' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77240> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql_query' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77240> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql_query' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c772e0> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql_query' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77380> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype_backend( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77600> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77600> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c776a0> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77740> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql_table' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77ba0> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql_table' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77c40> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s string_storage = 'python', func = 'read_sql_table' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77ce0> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s string_storage = 'python', func = 'read_sql_table' 1863s dtype_backend = 'numpy_nullable' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s dtype_backend_expected = .func at 0x7c5229c77d80> 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1863s def test_read_sql_dtype_backend_table( 1863s conn, 1863s request, 1863s string_storage, 1863s func, 1863s dtype_backend, 1863s dtype_backend_data, 1863s dtype_backend_expected, 1863s ): 1863s if "sqlite" in conn and "adbc" not in conn: 1863s request.applymarker( 1863s pytest.mark.xfail( 1863s reason=( 1863s "SQLite actually returns proper boolean values via " 1863s "read_sql_table, but before pytest refactor was skipped" 1863s ) 1863s ) 1863s ) 1863s # GH#50048 1863s conn_name = conn 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql_table' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql_table' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql_table' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql_table' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql_query' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql_query' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql_query' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = dtype_backend_data 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql_query' 1863s dtype_backend_data = a b c d e f g h 1863s 0 1 1 1.5 1.5 True True a a 1863s 1 2 2.0 False False b b 1863s 2 3 3 2.5 2.5 None True c None 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1863s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_chunksize_empty_dtypes(conn, request): 1863s # GH#50245 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1863s ) 1863s conn = request.getfixturevalue(conn) 1863s dtypes = {"a": "int64", "b": "object"} 1863s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1863s expected = df.copy() 1863s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_chunksize_empty_dtypes(conn, request): 1863s # GH#50245 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1863s ) 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_chunksize_empty_dtypes(conn, request): 1863s # GH#50245 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1863s ) 1863s conn = request.getfixturevalue(conn) 1863s dtypes = {"a": "int64", "b": "object"} 1863s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1863s expected = df.copy() 1863s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s def test_chunksize_empty_dtypes(conn, request): 1863s # GH#50245 1863s if "adbc" in conn: 1863s request.node.add_marker( 1863s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1863s ) 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s > sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3.13/socket.py:864: in create_connection 1863s raise exceptions[0] 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s address = ('localhost', 3306), timeout = 10, source_address = None 1863s 1863s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1863s source_address=None, *, all_errors=False): 1863s """Connect to *address* and return the socket object. 1863s 1863s Convenience function. Connect to *address* (a 2-tuple ``(host, 1863s port)``) and return the socket object. Passing the optional 1863s *timeout* parameter will set the timeout on the socket instance 1863s before attempting to connect. If no *timeout* is supplied, the 1863s global default timeout setting returned by :func:`getdefaulttimeout` 1863s is used. If *source_address* is set it must be a tuple of (host, port) 1863s for the socket to bind as a source address before making the connection. 1863s A host of '' or port 0 tells the OS to use the default. When a connection 1863s cannot be created, raises the last error if *all_errors* is False, 1863s and an ExceptionGroup of all errors if *all_errors* is True. 1863s """ 1863s 1863s host, port = address 1863s exceptions = [] 1863s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1863s af, socktype, proto, canonname, sa = res 1863s sock = None 1863s try: 1863s sock = socket(af, socktype, proto) 1863s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1863s sock.settimeout(timeout) 1863s if source_address: 1863s sock.bind(source_address) 1863s > sock.connect(sa) 1863s E ConnectionRefusedError: [Errno 111] Connection refused 1863s 1863s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1863s 1863s During handling of the above exception, another exception occurred: 1863s 1863s self = 1863s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1863s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'mysql_pymysql_conn' 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1863s with mysql_pymysql_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1863s self.connect() 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s self = , sock = None 1863s 1863s def connect(self, sock=None): 1863s self._closed = False 1863s try: 1863s if sock is None: 1863s if self.unix_socket: 1863s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1863s sock.settimeout(self.connect_timeout) 1863s sock.connect(self.unix_socket) 1863s self.host_info = "Localhost via UNIX socket" 1863s self._secure = True 1863s if DEBUG: 1863s print("connected using unix_socket") 1863s else: 1863s kwargs = {} 1863s if self.bind_address is not None: 1863s kwargs["source_address"] = (self.bind_address, 0) 1863s while True: 1863s try: 1863s sock = socket.create_connection( 1863s (self.host, self.port), self.connect_timeout, **kwargs 1863s ) 1863s break 1863s except OSError as e: 1863s if e.errno == errno.EINTR: 1863s continue 1863s raise 1863s self.host_info = "socket %s:%d" % (self.host, self.port) 1863s if DEBUG: 1863s print("connected using socket") 1863s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1863s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1863s sock.settimeout(None) 1863s 1863s self._sock = sock 1863s self._rfile = sock.makefile("rb") 1863s self._next_seq_id = 0 1863s 1863s self._get_server_information() 1863s self._request_authentication() 1863s 1863s # Send "SET NAMES" query on init for: 1863s # - Ensure charaset (and collation) is set to the server. 1863s # - collation_id in handshake packet may be ignored. 1863s # - If collation is not specified, we don't know what is server's 1863s # default collation for the charset. For example, default collation 1863s # of utf8mb4 is: 1863s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1863s # - MySQL 8.0: utf8mb4_0900_ai_ci 1863s # 1863s # Reference: 1863s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1863s # - https://github.com/wagtail/wagtail/issues/9477 1863s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1863s self.set_character_set(self.charset, self.collation) 1863s 1863s if self.sql_mode is not None: 1863s c = self.cursor() 1863s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1863s c.close() 1863s 1863s if self.init_command is not None: 1863s c = self.cursor() 1863s c.execute(self.init_command) 1863s c.close() 1863s 1863s if self.autocommit_mode is not None: 1863s self.autocommit(self.autocommit_mode) 1863s except BaseException as e: 1863s self._rfile = None 1863s if sock is not None: 1863s try: 1863s sock.close() 1863s except: # noqa 1863s pass 1863s 1863s if isinstance(e, (OSError, IOError)): 1863s exc = err.OperationalError( 1863s CR.CR_CONN_HOST_ERROR, 1863s f"Can't connect to MySQL server on {self.host!r} ({e})", 1863s ) 1863s # Keep original exception and traceback to investigate error. 1863s exc.original_exception = e 1863s exc.traceback = traceback.format_exc() 1863s if DEBUG: 1863s print(exc.traceback) 1863s > raise exc 1863s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s conn = request.getfixturevalue(conn) 1863s table = "test" 1863s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1863s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1863s return func(*args, **kwargs) 1863s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1863s return sql.to_sql( 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1863s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1863s return SQLDatabase(con, schema, need_transaction) 1863s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1863s con = self.exit_stack.enter_context(con.connect()) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s conn = 'postgresql_psycopg2_conn' 1863s request = > 1863s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1863s 1863s @pytest.mark.parametrize("conn", all_connectable) 1863s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1863s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1863s def test_read_sql_dtype(conn, request, func, dtype_backend): 1863s # GH#50797 1863s > conn = request.getfixturevalue(conn) 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1863s fixturedef = self._get_active_fixturedef(argname) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1863s fixturedef.execute(request=subrequest) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1863s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1863s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1863s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1863s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1863s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1863s return (yield) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1863s result = call_fixture_func(fixturefunc, request, kwargs) 1863s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1863s fixture_result = next(generator) 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1863s with postgresql_psycopg2_engine.connect() as conn: 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________________ test_psycopg2_schema_support _________________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s 1863s @pytest.mark.db 1863s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 1863s conn = postgresql_psycopg2_engine 1863s 1863s # only test this for postgresql (schema's not supported in 1863s # mysql/sqlite) 1863s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1863s 1863s # create a schema 1863s > with conn.connect() as con: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s _________________________ test_self_join_date_columns __________________________ 1863s self = 1863s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s connection = None, _has_events = None, _allow_revalidate = True 1863s _allow_autobegin = True 1863s 1863s def __init__( 1863s self, 1863s engine: Engine, 1863s connection: Optional[PoolProxiedConnection] = None, 1863s _has_events: Optional[bool] = None, 1863s _allow_revalidate: bool = True, 1863s _allow_autobegin: bool = True, 1863s ): 1863s """Construct a new Connection.""" 1863s self.engine = engine 1863s self.dialect = dialect = engine.dialect 1863s 1863s if connection is None: 1863s try: 1863s > self._dbapi_connection = engine.raw_connection() 1863s 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s 1863s The above exception was the direct cause of the following exception: 1863s 1863s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1863s 1863s @pytest.mark.db 1863s def test_self_join_date_columns(postgresql_psycopg2_engine): 1863s # GH 44421 1863s conn = postgresql_psycopg2_engine 1863s from sqlalchemy.sql import text 1863s 1863s create_table = text( 1863s """ 1863s CREATE TABLE person 1863s ( 1863s id serial constraint person_pkey primary key, 1863s created_dt timestamp with time zone 1863s ); 1863s 1863s INSERT INTO person 1863s VALUES (1, '2021-01-01T00:00:00Z'); 1863s """ 1863s ) 1863s > with conn.connect() as con: 1863s 1863s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1863s return self._connection_cls(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1863s Connection._handle_dbapi_exception_noconnection( 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1863s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1863s self._dbapi_connection = engine.raw_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1863s return self.pool.connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1863s return _ConnectionFairy._checkout(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1863s fairy = _ConnectionRecord.checkout(pool) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1863s rec = pool._do_get() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1863s return self._create_connection() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1863s return _ConnectionRecord(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1863s self.__connect() 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1863s with util.safe_reraise(): 1863s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1863s raise exc_value.with_traceback(exc_tb) 1863s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1863s self.dbapi_connection = connection = pool._invoke_creator(self) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1863s return dialect.connect(*cargs, **cparams) 1863s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1863s return self.loaded_dbapi.connect(*cargs, **cparams) 1863s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1863s 1863s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1863s connection_factory = None, cursor_factory = None 1863s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1863s kwasync = {} 1863s 1863s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1863s """ 1863s Create a new database connection. 1863s 1863s The connection parameters can be specified as a string: 1863s 1863s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1863s 1863s or using a set of keyword arguments: 1863s 1863s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1863s 1863s Or as a mix of both. The basic connection parameters are: 1863s 1863s - *dbname*: the database name 1863s - *database*: the database name (only as keyword argument) 1863s - *user*: user name used to authenticate 1863s - *password*: password used to authenticate 1863s - *host*: database host address (defaults to UNIX socket if not provided) 1863s - *port*: connection port number (defaults to 5432 if not provided) 1863s 1863s Using the *connection_factory* parameter a different class or connections 1863s factory can be specified. It should be a callable object taking a dsn 1863s argument. 1863s 1863s Using the *cursor_factory* parameter, a new default cursor factory will be 1863s used by cursor(). 1863s 1863s Using *async*=True an asynchronous connection will be created. *async_* is 1863s a valid alias (for Python versions where ``async`` is a keyword). 1863s 1863s Any other keyword parameter will be passed to the underlying client 1863s library: the list of supported parameters depends on the library version. 1863s 1863s """ 1863s kwasync = {} 1863s if 'async' in kwargs: 1863s kwasync['async'] = kwargs.pop('async') 1863s if 'async_' in kwargs: 1863s kwasync['async_'] = kwargs.pop('async_') 1863s 1863s dsn = _ext.make_dsn(dsn, **kwargs) 1863s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1863s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1863s E Is the server running on that host and accepting TCP/IP connections? 1863s E 1863s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1863s 1863s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1863s =============================== warnings summary =============================== 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 1863s /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 1863s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 1863s /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 1863s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 1863s /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 1863s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 1863s /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 1863s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 1863s /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 1863s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 1863s /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 1863s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 1863s /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 1863s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 1863s /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 1863s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 1863s /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 1863s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 1863s /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 1863s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 1863s /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 1863s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 1863s /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 1863s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 1863s /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 1863s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 1863s /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 1863s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 1863s /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 1863s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 1863s /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 1863s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 1863s /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 1863s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 1863s /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 1863s @pytest.mark.db 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 1863s /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 1863s @pytest.mark.db 1863s 1863s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 1863s /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 1863s @pytest.mark.skip_ubsan 1863s 1863s io/test_sql.py: 1535 warnings 1863s tools/test_to_datetime.py: 978 warnings 1863s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=24358) is multi-threaded, use of fork() may lead to deadlocks in the child. 1863s pid = os.fork() 1863s 1863s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1863s /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-2l30tlh7' 1863s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1863s 1863s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1863s /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-s8m0vm0j' 1863s config.cache.set("cache/lastfailed", self.lastfailed) 1863s 1863s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1863s /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-ow59ps08' 1863s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1863s 1863s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1863s =========================== short test summary info ============================ 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1863s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1863s 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] 1863s 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] 1863s 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] 1863s 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] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1863s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1863s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 565.75s (0:09:25) = 1864s autopkgtest [17:54:44]: test ignoredtests: -----------------------] 1865s ignoredtests PASS 1865s autopkgtest [17:54:45]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 1865s autopkgtest [17:54:45]: @@@@@@@@@@@@@@@@@@@@ summary 1865s command1 PASS 1865s unittests3 PASS 1865s ignoredtests PASS 1869s nova [W] Skipping flock for amd64 1869s Creating nova instance adt-questing-amd64-pandas-20250506-172340-juju-7f2275-prod-proposed-migration-environment-15-0cc471d2-e78e-4b82-b0d7-51078cff8a31 from image adt/ubuntu-questing-amd64-server-20250506.img (UUID f1864fa2-149c-4e5d-800d-c5107d8a2f35)... 1869s nova [W] Timed out waiting for fa5c3d3c-d7cd-45f1-88f0-21b02a438713 to get deleted.